python - Scrape webpage after form fill -


im trying scrape response website using pre-filled zip: zip who (i.e. zip code filled in.) tried using scrapy shell follows

scrapy shell http://zipwho.com/?zip=77098&mode=zip 

but response not contain form-filled page, content main zipwho.com page , without details specific zip code. tried filling in form information using requests , lxml, doing wrong.

import requests import lxml.html lh url = 'http://zipwho.com'  form_data = {     'zip': '77098'     } response = requests.post(url, data=form_data) tree = lh.document_fromstring(response.content) tree.xpath('//td[@class="keysplit"]') 

and table element data (td class = 'keysplit') still not exist. if have ideas working (hopefully simple in requests & lxml) best.

the reason can't find data in html it's generated dynamically script. if @ first script in html, you'll see function called getdata contains data want. script later uses function build see in browser.

so scrape data i'd extract directly script: string function returns, split , , on.

good luck!


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -