cob007 19 Posted December 6, 2019 Report Share Posted December 6, 2019 I have a list which contains around 10 items in a single list item of 0. Is it possible to separate all the items into 10 different list items, as u can see in the image, there is a space between each of those items. Unfortunately while scarping itself ive not been able to seperate them even after using delimiter of new line Quote Link to post Share on other sites
HelloInsomnia 1103 Posted December 6, 2019 Report Share Posted December 6, 2019 Can you paste some of the text using the code button on the wysiwyg editor. Quote Link to post Share on other sites
cob007 19 Posted December 6, 2019 Author Report Share Posted December 6, 2019 Can you paste some of the text using the code button on the wysiwyg editor.HI Nick, 1. I am able to split it into seperate list items using new line, set(#rr,$plugin function("HeopasCustom.dll", "$Heopas HTTP Get", "https://www.amazon.com/Girl-Wash-Your-Face-Believing-ebook/product-reviews/B072TMB75T/ref=cm_cr_getr_d_paging_btm_prev_1?ie=UTF8&reviewerType=all_reviews&pageNumber=1", "", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0", "", "", ""),"Global")wait(5)add list to list(%review,$list from text($plugin function("HTTP post.dll", "$xpath parser", #rr, "//span[@class=\"a-size-base review-text review-text-content\"][1]", "InnerText", "HTML"),$new line),"Delete","Global") The above code gives 11 list items with single blank item 2. However i want to break the text because i dont want entire text show it as a line and for which i was calling a seperate function to do the same as below, however if i call this function the text is no longer part of seperate list items. define $new(#var) { set(#count,$text length(#var),"Global") set(#charactersperline,200,"Global") set(#charcnt,0,"Global") set(#index,"-1","Global") loop(#count) { increment(#index) increment(#charcnt) set(#letter,$substring(#var,#index,1),"Global") if($both(#charcnt > #charactersperline,#letter = " ")) { then { set(#line,"{#line}{$new line}","Global") set(#charcnt,0,"Global") } else { set(#line,"{#line}{#letter}","Global") } } } return(#line) if i try to call the above function inside while scraping like this, it still shows up as a single list item add list to list(%review,$list from text($new($plugin function("HTTP post.dll", "$xpath parser", #rr, "//span[@class=\"a-size-base review-text review-text-content\"]", "InnerText", "HTML")),""),"Delete","Global") I have also attached the textreview.txt Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted December 7, 2019 Report Share Posted December 7, 2019 First I would use only 1 plugin for this heopas/http post. Have you tried using a space for a delimiter? Quote Link to post Share on other sites
cob007 19 Posted December 7, 2019 Author Report Share Posted December 7, 2019 First I would use only 1 plugin for this heopas/http post. Have you tried using a space for a delimiter?Okay, thanks, no i did not use space as a demiliter, sorry i didnt know that , we have to calculate total space between two paragaphs before using as space Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted December 7, 2019 Report Share Posted December 7, 2019 It is helpful to show the desired end result as well. I still don't understand what you're trying to do exactly. Quote Link to post Share on other sites
cob007 19 Posted December 8, 2019 Author Report Share Posted December 8, 2019 Sorry i wasn't clear, here is what i trying to do 1. I want to scrape all these reviews from kindle, https://www.amazon.com/Girl-Wash-Your-Face-Believing/product-reviews/1400201659/ref=cm_cr_dp_d_show_all_btm?ie=UTF8&reviewerType=all_reviews If you see each page has 10 reviews, so for that im using http request and getting all the data using xpath which gives me 11 list items with one blank list item which can be removed set(#rr,$plugin function("HeopasCustom.dll", "$Heopas HTTP Get", "https://www.amazon.c...s&pageNumber=1", "", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0", "", "", ""),"Global")wait(5)add list to list(%review,$list from text($plugin function("HTTP post.dll", "$xpath parser", #rr, "//span[@class=\"a-size-base review-text review-text-content\"], "InnerText", "HTML"),$new line),"Delete","Global")2. But since i want to display the scraped data on a datagrid( but not all on a single line otherwise user will have to use the scrollviewer of the datagrid extensively to read, so i want to split that review text at 150 or 200 lines for easy reading , for which im trying to call this custom function at the same time define $new(#var) { set(#count,$text length(#var),"Global") set(#charactersperline,200,"Global") set(#charcnt,0,"Global") set(#index,"-1","Global") loop(#count) { increment(#index) increment(#charcnt) set(#letter,$substring(#var,#index,1),"Global") if($both(#charcnt > #charactersperline,#letter = " ")) { then { set(#line,"{#line}{$new line}","Global") set(#charcnt,0,"Global") } else { set(#line,"{#line}{#letter}","Global") } } } return(#line) 3. So combining the scraping and this custom function as below final code, the result im getting you see in the notepad attached where all the scraped items are broken into 200 lines but i want them to be on seperate list items but they are getting combined into a singe list item. clear all dataset(#rr,$plugin function("HeopasCustom.dll", "$Heopas HTTP Get", "https://www.amazon.com/Girl-Wash-Your-Face-Believing-ebook/product-reviews/B072TMB75T/ref=cm_cr_getr_d_paging_btm_prev_1?ie=UTF8&reviewerType=all_reviews&pageNumber=1", "", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0", "", "", ""),"Global")add list to list(%review,$list from text($new($plugin function("HTTP post.dll", "$xpath parser", #rr, "//span[@class=\"a-size-base review-text review-text-content\"]", "InnerText", "HTML")),""),"Delete","Global")define $new(#var) { set(#count,$text length(#var),"Global") set(#charactersperline,200,"Global") set(#charcnt,0,"Global") set(#index,"-1","Global") loop(#count) { increment(#index) increment(#charcnt) set(#letter,$substring(#var,#index,1),"Global") if($both(#charcnt > #charactersperline,#letter = " ")) { then { set(#line,"{#line}{$new line}","Global") set(#charcnt,0,"Global") } else { set(#line,"{#line}{#letter}","Global") } } } return(#line)} In order to save coding multiple defines, i was trying to call the custom function of breaking the text into 200 lines each line at the same time. So in short, i want to scrape all the reviews from the kindle review page, then split each line of those reviews into 150-200 lines max and then show them as separate list itemsbut right now everything is being shown in single list item.review.txt Quote Link to post Share on other sites
Pete 121 Posted December 8, 2019 Report Share Posted December 8, 2019 blocked from posting my code here and from sending it in a pm Quote Link to post Share on other sites
cob007 19 Posted December 8, 2019 Author Report Share Posted December 8, 2019 blocked from posting my code here and from sending it in a pmive just sent you a PM Quote Link to post Share on other sites
cob007 19 Posted December 8, 2019 Author Report Share Posted December 8, 2019 to give an example on what i was trying to do, see this question below assked in forum, whenever xpath scrapes lengthy text or descrition, everything is shown in one big line and i wanted to break up that text for better readability when displayed on datagrid https://stackoverflow.com/questions/25721225/breaking-a-lengthy-row-into-multiple-rows-using-xpath-expression-in-altova-style Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted December 9, 2019 Report Share Posted December 9, 2019 ui open file("in file",#in file) clear list(%reviews) add list to list(%reviews,$list from file($trim(#in file)),"Delete","Global") So, I read the file into ubot and used $trim. It separates into 83 items. Is this desired?if so just read the list back in. 1 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.