python - How to extract a javascript variable using regular expression -


i need extract javascript variable containing multiline json remote page using python script(2.7), , want use regex this, pattern not return anything

what doing wrong ?

here's code :

request = urllib2.request("http://somesite.com/affiliates/") result = urllib2.urlopen(request) affiliates = re.findall('#var affiliates = (.*?);\s*$#m', result.read()) print affiliates 

if @ docs re.findall(pattern, string, flags=0), you'll see need change how you're using it

affiliates = re.findall('var affiliates = (.*?);\s*$', result.read(), re.m) 

you might want consider how whitespace can sloppy in javascript.


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -