import requests,json url = "https://www.yijiupi.com/v31/Product/ListProduct" headers = { 'Accept': 'application/json, text/plain, */*', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'zh-CN,zh;q=0.9', 'Content-Type': 'application/json;charset=UTF-8', 'Host': 'www.yijiupi.com', 'Referer': 'https://www.yijiupi.com/', 'token': '6737c474-dfb0-45f5-aba0-7c0c545fc82d', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36', 'Connection': 'keep-alive', 'Content-Length': '320', 'Origin': 'https://www.yijiupi.com', } payload = {"currentPage":1,"serviceTime":"2019-04-27 10:31:30","data":{"sonCategoryId":"3070","brandId":"","firstCategoryId":"","specialAreaId":"","categoryIds":["3070"],"brandIds":[],"isAscending":"","saleModel":-1,"searchModes":[],"sort":0,"shopId":"","currentPage":1,"pageSize":60},"pageSize":60,"addressId":1205414,"deviceType":3} #原生的payload为{"currentPage":1,"data":{"sonCategoryId":"3070","brandId":"","firstCategoryId":"","searchKey":null,"specialAreaId":"","categoryIds":["3070"],"brandIds":[],"labelId":null,"isAscending":"","saleModel":-1,"searchModes":[],"sort":0,"shopId":"","currentPage":1,"pageSize":60},"pageSize":60,"addressId":1205414,"deviceType":3} *********************这里需要把value为“null”的元素去掉,例如labelId":null,和"searchKey":null,(这里需要特别注意) response = requests.post(url=url,headers=headers,data=json.dumps(payload)) text = response.text print(text)
这里需要特别注意的是,把payload里面value为‘null’的值去掉。