403 forbidden(Spider error)

这里写图片描述

(To ensure the safety, edit some words.)
When I run a spider on Taobao get the error 403.

As the above page image, it receive the response successfully.
But if you open the request url on a new web, it will receive 403 forbidden, I do not know what happened there.

I try imitate the request by using postman but also got the 403.

After that, I found that some params like :authority:scheme and these things make me find that postman not support http2, so I try make it by python requests.

Then an error occured. I throw the symbol colon, then get the real response.

There are still something make me boring.
Anyway, I make it.

Finally, show you the code:

import requests

url = "https://detailskip.taobao.com/service/getData/1/p1/item/detail/sib.htm"

querystring = {"itemId":"537337861521","sellerId":"1096320518","modules":"dynStock,qrcode,viewer,price,contract,duty,xmpPromotion,delivery,upp,activity,fqg,zjys,amountRestriction,couponActivity,soldQuantity,tradeContract","callback":"onSibRequestSuccess"}

headers = {
    'x-requested-with': "XMLHttpRequest",
    'accept': "*/*",
    'accept-encoding': "gzip, deflate, sdch, br",
    'accept-language': "zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4",
    'cookie': "thw=cn; t=91a9f63dff91a1c00e8552a2229bf49f; cookie2=1cb5763df4cb43b824eb1fcd18; v=0; cna=; _tb_token_=04eeb53d3511; uc1=cookie14=UoW%2Bvf0NDvrQ%3D%3D; l=AsbGqOOlKA9YtY278R47/14olrdIygrl; isg=Ah4epUtxy28OGB8NkAaMWo4rb7SeFuJZFy2HfMinZ2FY67zFMG_naHjLhUWa",
    'referer': "https://item.taobao.com/item.htm?spm=a21fg.7938700.204843.1.sGwL2B&scm=1007.12144.81309.2193_1158&pvid=4fad7005-d521-4b2a-a27f-dc3d3bb3e557&id=532801124551",
    'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36",
    'authority':"detailskip.taobao.com",
    'method':"GET",
    'path':"/service/getData/1/p1/item/detail/sib.htm?itemId=532801124551&sellerId=367896056&modules=dynStock,qrcode,viewer,price,contract,duty,xmpPromotion,delivery,upp,activity,fqg,zjys,couponActivity,soldQuantity,tradeContract&callback=onSibRequestSuccess",
    'scheme':"https",
    'cache-control': "no-cache",
    'postman-token': "32d300ff-08db-6069-bde5-9d8e091915d1"
    }

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值