获取京东商品信息报错error pdos_captcha

2022-08-01,,,

获取京东商品信息报错error pdos_captcha

2020.7.20
python 请求商品信息出现 {“error”:“pdos_captcha”}。
添加header后解决问题:

# 参数货物id   返回值价格
def get_book_price(commodityID):
    Cookie = ''

    headers = {
        'User-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36',
        'Cookie': Cookie,
        'Connection': 'keep-alive',
        'Accept': '*/*',
        'Accept-Encoding': 'gzip, deflate, sdch',
        'Accept-Language': 'zh-CN,zh;q=0.8',
        'Host': 'p.3.cn',
        'Referer': 'https://book.jd.com/booktop/0-0-0.html?category=1713-0-0-0-10001-1'
    }

    url = "https://p.3.cn/prices/mgets"

    payload = {'skuIds': commodityID}

    response = requests.get(url, params=payload, headers=headers)

    # print(response.status_code)
    # print(str(response.content))
    reg = r'(?<=op":").+(?=",)'
    price = re.search(reg,str(response.content), flags=0).group()
    return price

本文地址:https://blog.csdn.net/qq_42599719/article/details/107461538

《获取京东商品信息报错error pdos_captcha.doc》

下载本文的Word格式文档,以方便收藏与打印。