首页 新闻 会员 周边 捐助

用python的requests 请求tmall的详情的一个请求报403错误的问题

0
[待解决问题]
描述一下问题:
1. 这个url呢,是用于获取tmall详情页的销量数据的请求;
2. 之前看到网上的一个解决方法(https://segmentfault.com/q/1010000008843066),现在这网站的示例也报403了。。
3. 经过多次尝试,时好时坏,同样的代码,过一会又能正常请求了
没什么辙了。。。求助

复制代码
import requests

def get_content(url):
s = requests.get(url, headers=headers)
    content = s.content.decode('gbk')
    print(content)
    return content

if __name__=="__main__":
headers = {
        "Host":"mdskip.taobao.com",
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate, br",
        "Accept-Language": "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3",
        "Cookie":"l=AurqcPuigwQdnQv7WvAfCoR1OlrRQW7h; isg=BHp6mNB79CHqYXpVEiRteXyyyKNcg8YEwjgLqoRvCI3ddxqxbLtOFUBGwwOrZ3ad; thw=cn; cna=VsJQERAypn0CATrXFEIahcz8; t=0eed37629fe7ef5ec0b8ecb6cd3a3577; tracknick=tb830309_22; _cc_=UtASsssmfA%3D%3D; tg=0; ubn=p; ucn=unzbyun; x=e%3D1%26p%3D*%26s%3D0%26c%3D0%26f%3D0%26g%3D0%26t%3D0%26__ll%3D-1%26_ato%3D0; miid=981798063989731689; hng=CN%7Czh-CN%7CCNY%7C156; um=0712F33290AB8A6D01951C8161A2DF2CDC7C5278664EE3E02F8F6195B27229B88A7470FD7B89F7FACD43AD3E795C914CC2A8BEB1FA88729A3A74257D8EE4FBBC; enc=1UeyOeN0l7Fkx0yPu7l6BuiPkT%2BdSxE0EqUM26jcSMdi1LtYaZbjQCMj5dKU3P0qfGwJn8QqYXc6oJugH%2FhFRA%3D%3D; ali_ab=58.215.20.66.1516409089271.6; mt=ci%3D-1_1; cookie2=104f8fc9c13eb24c296768a50cabdd6e; _tb_token_=ee7e1e1e7dbe7; v=0",
        "Referer": "https://detail.tmall.com/item.htm?id=542020037373&rn=ef4dc97f30c05c8ae00e231ca59e5e5d&abbucket=18",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0"
}
    url="https://mdskip.taobao.com/core/initItemDetail.htm?isUseInventoryCenter=false&cartEnable=true&service3C=false&isApparel=false&isSecKill=false&tmallBuySupport=true&isAreaSell=false&tryBeforeBuy=false&offlineShop=false&itemId=527909705030&showShopProm=false&cachedTimestamp=1524175497016&isPurchaseMallPage=false&isRegionLevel=false&household=false&sellerPreview=false&queryMemberRight=true&addressLevel=2&isForbidBuyItem=false"
get_content(url)
复制代码
洛雨寒殇的主页 洛雨寒殇 | 初学一级 | 园豆:5
提问于:2018-04-20 15:26
< >
分享
所有回答(2)
1

我刚才用浏览器访问了一下你的链接,连接不上,怎么用python爬取,你这个url有问题啊。

我不 | 园豆:154 (初学一级) | 2018-04-20 16:11
1

是权限问题。缺少token之类的参数

0bug | 园豆:149 (初学一级) | 2018-04-24 13:53
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册