Frozennnn
2021-09-08 11:50
采纳率: 100%
浏览 118

python 爬虫 post请求返回的数据不全,和postman模拟的不一样,关键内容是个空列表

本人小白用爬虫爬取辽宁省政府招标信息的代码如下:


import requests
import datetime
agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
head={
    "User-Agent":agent,
    }
url = "http://www.ccgp-liaoning.gov.cn/portalindex.do"
params = {
    "method": "getPubInfoList",
    "t_k": None,
    }
data = {  
    "current": 1,
    "rowCount": 10,
    "searchPhrase": None,
    "district": None,
    "releaseDateStart": (datetime.datetime.now() + datetime.timedelta(days=-60)).strftime('%Y-%m-%d'),
    "releaseDateEnd": datetime.datetime.now().strftime('%Y-%m-%d'),
    "infoTypeCode": 1001,
    "year": None,
    "title": "柴油",
    "privateOrCity": 1,
        }
try:
    response = requests.post(url, params=params, data=data, headers=head, timeout=10)
    print(response.text)

返回结果为,rows中没有数据


{"current":1,"rowCount":10,"rows":[],"total":0}

用postman模拟相同参数请返回有数据

img

img

尝试过headers中加入Cookie,然而并没有用

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题