allcapone1912 7 Posted March 25, 2015 Report Share Posted March 25, 2015 hi,need some help working on a scrape project and can not get the script working my code is simple: clear cookies clear all data navigate("http://www.tripadvisor.ca/Restaurants-g155032-Montreal_Quebec.html","Wait") wait(1) add list to list(%company name,$scrape attribute(<class="property_title ">,"innertext"),"Delete","Global") add list to table as column(&restaurant,0,0,%company name) add list to list(%company url,$scrape attribute(<class="property_title ">,"fullhref"),"Delete","Global") loop($list total(%company url)) { navigate($next list item(%company url),"Wait") wait(1) add list to list(%reviews,$scrape attribute(<property="v:count">,"innertext"),"Delete","Global") add list to table as column(&restaurant,0,1,%reviews) add list to list(%rating,$scrape attribute(<class="valueCount fr part">,"innertext"),"Delete","Global") add list to table as column(&restaurant,0,2,%rating) } so,i need to add to table columns for 5 type of rating(excellent good,average,poor and terrible)this part scrape all the 5 item but i dont know how to include them into table,each in new column add list to list(%rating,$scrape attribute(<class="valueCount fr part">,"innertext"),"Delete","Global")I am an ubot user for couple of weeks so please help me with this Quote Link to post Share on other sites
wiseguys 3 Posted March 25, 2015 Report Share Posted March 25, 2015 (edited) First off, if you're formatting as a table by adding lists to columns you want to switch all the 'add list to list' functions to "Don't delete duplicates" since some of the numbers in the later columns will be duplicated across multiple restaurants Here is the code to add each of the 5 review types to your table, each in a seperate column starting with excellent, ending at terrible clear list(%rexcellent) clear list(%verygood) clear list(%raverage) clear list(%rpoor) clear list(%rterrible) set(#rexcellent, $scrape attribute($element offset(<class="valueCount fr part">, 0), "innertext"), "Global") set(#rverygood, $scrape attribute($element offset(<class="valueCount fr part">, 1), "innertext"), "Global") set(#raverage, $scrape attribute($element offset(<class="valueCount fr part">, 2), "innertext"), "Global") set(#rpoor, $scrape attribute($element offset(<class="valueCount fr part">, 3), "innertext"), "Global") set(#rterrible, $scrape attribute($element offset(<class="valueCount fr part">, 4), "innertext"), "Global") add item to list(%rexcellent, #rexcellent, "Don\'t Delete", "Global") add item to list(%verygood, #rverygood, "Don\'t Delete", "Global") add item to list(%raverage, #raverage, "Don\'t Delete", "Global") add item to list(%rpoor, #rpoor, "Don\'t Delete", "Global") add item to list(%rterrible, #rterrible, "Don\'t Delete", "Global") add list to table as column(&restaurant, 0, 3, %rexcellent) add list to table as column(&restaurant, 0, 4, %verygood) add list to table as column(&restaurant, 0, 5, %raverage) add list to table as column(&restaurant, 0, 6, %rpoor) add list to table as column(&restaurant, 0, 7, %rterrible) Edited March 25, 2015 by wiseguys 1 Quote Link to post Share on other sites
ilovepizza 2 Posted March 25, 2015 Report Share Posted March 25, 2015 Or you could do it this way... clear cookiesclear all datanavigate("http://www.tripadvisor.ca/Restaurants-g155032-Montreal_Quebec.html","Wait")wait(1)add list to list(%company name,$scrape attribute(<class="property_title ">,"innertext"),"Delete","Global")add list to table as column(&restaurant,0,0,%company name)add list to list(%company url,$scrape attribute(<class="property_title ">,"fullhref"),"Delete","Global")set(#RowCounter,0,"Global")loop($list total(%company url)) { navigate($next list item(%company url),"Wait") wait(1) add list to list(%reviews,$scrape attribute(<property="v:count">,"innertext"),"Delete","Global") add list to table as column(&restaurant,0,1,%reviews) add list to table as row(&restaurant,#RowCounter,2,$scrape attribute(<class="valueCount fr part">,"innertext")) increment(#RowCounter)} (I guess this is what you were after) 1 Quote Link to post Share on other sites
allcapone1912 7 Posted March 25, 2015 Author Report Share Posted March 25, 2015 First off, if you're formatting as a table by adding lists to columns you want to switch all the 'add list to list' functions to "Don't delete duplicates" since some of the numbers in the later columns will be duplicated across multiple restaurants Here is the code to add each of the 5 review types to your table, each in a seperate column starting with excellent, ending at terrible clear list(%rexcellent) clear list(%verygood) clear list(%raverage) clear list(%rpoor) clear list(%rterrible) set(#rexcellent, $scrape attribute($element offset(<class="valueCount fr part">, 0), "innertext"), "Global") set(#rverygood, $scrape attribute($element offset(<class="valueCount fr part">, 1), "innertext"), "Global") set(#raverage, $scrape attribute($element offset(<class="valueCount fr part">, 2), "innertext"), "Global") set(#rpoor, $scrape attribute($element offset(<class="valueCount fr part">, 3), "innertext"), "Global") set(#rterrible, $scrape attribute($element offset(<class="valueCount fr part">, 4), "innertext"), "Global") add item to list(%rexcellent, #rexcellent, "Don\'t Delete", "Global") add item to list(%verygood, #rverygood, "Don\'t Delete", "Global") add item to list(%raverage, #raverage, "Don\'t Delete", "Global") add item to list(%rpoor, #rpoor, "Don\'t Delete", "Global") add item to list(%rterrible, #rterrible, "Don\'t Delete", "Global") add list to table as column(&restaurant, 0, 3, %rexcellent) add list to table as column(&restaurant, 0, 4, %verygood) add list to table as column(&restaurant, 0, 5, %raverage) add list to table as column(&restaurant, 0, 6, %rpoor) add list to table as column(&restaurant, 0, 7, %rterrible) thanks for your help,its i've been looking for Quote Link to post Share on other sites
wiseguys 3 Posted March 25, 2015 Report Share Posted March 25, 2015 (edited) thanks for your help,its i've been looking for No problem but ilovepizza's code is a bit cleaner if you understand what's going on with it. My example was for beginners adding lists to columns as you had already been doing successfully. Edited March 25, 2015 by wiseguys Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.