def walkCategories(session, response):
try:
root = html.fromstring(response.text)
url = response.url
categories = root.xpath(".//select[@name='ctl00$ctl00$ctl00$mainContent$localizedContent$bodyCenter$adsPanel$lbProductCategory']/option")
global startCat
for iCat, category in enumerate(categories[startCat:], startCat):
startCat=0
rsrc = category.xpath("./@value")[0]
text = category.xpath(".//text()")[0]
print('Category="%s", iCat=%d'%(text, iCat))
formdata= {"__EVENTTARGET": "ctl00$ctl00$ctl00$mainContent$localizedContent$bodyCenter$adsPanel$lbProductCategory",
"ctl00$ctl00$ctl00$mainContent$localizedContent$bodyCenter$adsPanel$lbProductCategory": rsrc,
"__ASYNCPOST:": "true"}
resp2 = form_submit(session, root, url,
"aspnetForm",
formdata,
{"Referer": url})
if not resp2:
continue
walkFamilies(session, resp2)
except BaseException as ex:
print('iCat=%d, cat="%s"'%(iCat, text))
traceback.print_exc()
netgear_form_submit_crawler.py 文件源码
python
阅读 31
收藏 0
点赞 0
评论 0
评论列表
文章目录