headers={'Accept':'*/*',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Ajax-method': 'GetPageJYXTXXFB',
'Connection': 'keep-alive',
'Content-Length': '129',
'Content-Type': 'text/plain; charset=UTF-8',
'Cookie': 'ASP.NET_SessionId=vdl5ooxkjkazwszgvj5woewh',
'Host': 'ggzy.yibin.gov.cn',
'Origin': 'http://ggzy.yibin.gov.cn',
'Referer': 'http://ggzy.yibin.gov.cn/Jyweb/ZhaoBaoGongGaoList.aspx?Type=%e5%bb%ba%e8%ae%be%e5%b7%a5%e7%a8%8b&SubType=260',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36',
} #模仿浏览器
payload=[i*15,15,"FBSJ DESC","XMMC","","XXLB ={0} AND XTType={1} AND ZBFS != 2","[{\"pvalue\":\"260\"},{\"pvalue\":\"1\"}]"] #Request payload里面的信息
rsp=requests.post(url1,data=json.dumps(payload),headers = headers) #用Request payload里面的信息发送post请求
data_a=rsp.content
def parse_js(expr):
obj = eval(expr, type('Dummy', (dict,), dict(__getitem__=lambda s, n: n))())
return obj
list_a = parse_js(data_a) # 把 json字典({KEY:'value'}) 转换为python的字典({'key':'value'})