一个练习题的代码

import requests
import re
header={
'Cookie': 'gxfda_supervise_id=0000QdmIkkDNPaUemUTEEPvggv6:19lo8hslj',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36',
'Referer': 'http://oa.gxfda.gov.cn/gxfda_supervise/appnet/appEntpList.action?entpType=002',
}
source=requests.get('http://www.gxfda.gov.cn/gxfdanet/gxdataylqxscqy.jhtml',headers=header).text
# print(source)
url=re.compile('<iframe border="0" frameborder="0" framespacing="0" height="725" marginheight="0" marginwidth="0" name="12" noresize scrolling="no" src="(.*?)" width="1003" vspale="0"> </iframe>',re.S).findall(source)
print(url)
source1=requests.get(url[0],headers=header).text
# print(source1)
token=re.compile('<input type="hidden" name="token" value="(.*?)" />').findall(source1)
print(token[0])
data={
'token':token[0],
'pageNumber': '1'
}
s=requests.post('http://oa.gxfda.gov.cn/gxfda_supervise/appnet/appEntpList.action',headers=header,data=data).text
print(s)

猜你喜欢

转载自www.cnblogs.com/mypath/p/9274445.html