Regex filter for iMacros -


i'm trying scrape search result counter google serp. works google spreadsheets, importxml , regexreplace, not always, because of spreadsheets fault. i'm trying accomplish imacros , can't scraped string correctly filtered out.

in g spreadsheets use

=regexreplace(importxml("https://www.google.com/search?q=test&hl=en&as_qdr=m","//div[@id='resultstats']"),".*?([0-9,]+) (w|r)esults?","$1") 

the whole imported string in id="resultsstats" about 4,290,000 results here regex .*?([0-9,]+) (w|r)esults? filters words out results number. said, doesn't work reliably in spreadsheets.

the question is: how use regex imacros number? use imacros code:

version build=8881205 recorder=fx set !timeout_step 0 set !errorignore yes tab t=1 set !datasource sr1.csv  set !datasource_columns 1 set !loop 1 set !datasource_line {{!loop}} set !var1 eval("var randomnumber=math.floor(math.random()*45 + 16); randomnumber;") url goto={{!col1}} wait seconds={{!var1}} tag pos=1 type=div attr=id:resultstats extract=txt  add !extract {{!urlcurrent}} set !extract eval("decodeuri('{{!extract}}');") saveas type=extract folder=* file=+{{!now:ddmmyyyy}}.csv 

it's simple do:

' ... '  tag pos=1 type=div attr=id:resultstats extract=txt set !extract eval("'{{!extract}}'.match(/[0-9,]+/);")  ' ... ' 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -