爬虫遇到了同一个url参数只有一个不同参不知道该怎么爬了

https://spcjsac.gsxt.gov.cn/

左边

img

右边

img

页面

img


怎么只爬取其中一边的数据


import requests

if __name__ == '__main__':
    url = 'https://spcjsac.gsxt.gov.cn/api/goods/data'
    # UA伪装
    url1 = "https://spcjsac.gsxt.gov.cn/api/goods/data?food_type=&order_by=time&pageNumber=1&pageSize=10&goods_enterprise=&sampling_province=&name_first_letter=&food_name=&bar_code=&check_flag=q"
    headers = {
        "User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36',
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
        "Accept": "application/json, text/javascript, */*; q=0.01",
        "Connection": "keep-alive"
    }
    data = {
        'food_type': '',
        'order_by': 'time',
        'pageNumber': '1',
        'pageSize': '10',
        'goods_enterprise': '广东',
        'sampling_province': '',
        'name_first_letter': '',
        'food_name': '',
        'bar_code': '',
        'check_flag': 'uq'
    }
    # response = requests.get(url=url1, data=data, headers=headers,verify=False)
    response = requests.post(url=url, data=data, headers=headers).json()

    print(response)

这个错误跟python 版本,openssl 版本有关。。以上代码在python 3.6 版本运行成功,你换个版本吧

有人能帮帮我吗

为什么不会爬,你都分析对了啊。就是那个uq 和q 控制左右的。uq 是不安全。q是符合质量的列表
https://spcjsac.gsxt.gov.cn/api/goods/data?food_type=&order_by=time&pageNumber=1&pageSize=10&goods_enterprise=&sampling_province=&name_first_letter=&food_name=&bar_code=&check_flag=q

我的代码:
import requests
import json
if name == 'main':
url = 'https://spcjsac.gsxt.gov.cn/api/goods/data'
data = {
'food_type':'',
'order_by': 'time',
'pageNumber': '1',
'pageSize': '10',
'goods_enterprise': '广东',
'sampling_province': '',
'name_first_letter': '',
'food_name': '',
'bar_code': '',
'check_flag': 'q'
}
#UA伪装
headers = {
'user-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36'
}
response = requests.post(url=url,data=data,headers=headers)
food_obj = response.json()
print(food_obj)
fp = open('./food.json','w',encoding='utf-8')
json.dump(food_obj,fp=fp,ensure_ascii=False)
print('爬取成功!!!')

报错:

img

这个可以实施其他的方法