Dallashox 2 Posted July 18, 2017 Report Share Posted July 18, 2017 Hi I'm learning Regex but I've encountered a problem when looking at source of a page. On amazon you can see 3 monitors per line with prices. I essentially want the monitors at the start of each line which means every 1st, 4th line and so on. https://www.amazon.com/Best-Sellers-Electronics-Computer-Monitors/zgbs/electronics/1292115011 My code is: (?<='true'>\n\s+)\w.*.*(?=\n\s+</div>) How do I get every highlighted 1st, 4th, 7th, 10th line (starting at line 1 then +3) regex? Quote Link to post Share on other sites
HelloInsomnia 1103 Posted July 18, 2017 Report Share Posted July 18, 2017 What are you trying to get the title or link or what? Quote Link to post Share on other sites
Dallashox 2 Posted July 20, 2017 Author Report Share Posted July 20, 2017 The title Quote Link to post Share on other sites
HelloInsomnia 1103 Posted July 20, 2017 Report Share Posted July 20, 2017 Give this a try: clear list(%containers) add list to list(%containers,$scrape attribute(<class="zg_itemImmersion">,"innerhtml"),"Delete","Global") clear list(%titles) loop($list total(%containers)) { set(#container,$next list item(%containers),"Global") set(#title,$nothing,"Global") set(#title,$find regular expression(#container,"(?<=true\"\\stitle=\").*?(?=\">)"),"Global") if($comparison(#title,"=",$nothing)) { then { set(#title,$find regular expression(#container,"(?<=true\">).*?(?=<\\/div)"),"Global") } else { } } add item to list(%titles,#title,"Don\'t Delete","Global") } What that does is scrape the result container for each item and then looks in each for a regex that would pull the title out of the div tag if it exists and if it does not (if the title is short) then look for it in the normal place (the text of the actual link). 1 Quote Link to post Share on other sites
Dallashox 2 Posted July 21, 2017 Author Report Share Posted July 21, 2017 Thanks man 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.