python 的post表单 总是无法翻页

sun001 发布于 2016/10/04 22:11
阅读 289
收藏 0
import re import requests as req
url = r'http://app2.bjepb.gov.cn/cpout/showout/listresult.aspx' UA = {'User-Agent':'Mozilla/5.0'}
formdata = { '__EVENTTARGET':"", '__EVENTARGUMENT':"", '__VIEWSTATE':'', 'ddlcounty':"市级", 'ddlPZYear': '2014', 'txtAppName': "", 'AspNetPager_input': '30', 'AspNetPager': '跳转' }
ssn = req.Session()
ssn.headers = UA
rsp = ssn.get(url)
html = rsp.text
vs = re.findall(r'<input[^>]+?name="__VIEWSTATE"[^>]+?value="([^"]+)',html)[0]
formdata['__VIEWSTATE'] = vs
rsp = ssn.post(url, data=formdata)
html = rsp.text
pg = ''.join(re.findall(r'(当前页:).+?(\d+)',html, re.S)[0]) print(pg)

加载中
返回顶部
顶部