《广西壮族自治区食品药品监督管理局》代码

本文介绍了一种使用Python的requests和正则表达式从广西食品药品监督管理局网站抓取企业名单数据的方法。通过设置请求头,获取网页源码,解析iframe链接及隐藏字段token,最终实现post请求获取数据。
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)

转载于:https://www.cnblogs.com/palace/p/9599608.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值