花了几十分钟帮你看了下,该网站有一定的反扒手段,初步判断请求不能太频繁。
requests方法确实不行。
这个能跑,和2楼一样,加上代{过}{滤}理请求成功的概率会大一些。
[Python] 纯文本查看 复制代码 import http.client
import json
conn = http.client.HTTPSConnection("shopee.com.my")
payload = ''
headers = {
'sec-ch-ua': '"Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24"',
'sz-token': 'Ra/NJSFhMbpYXlWXB/kMKw==|tbtAeRuQraLaHXP0PPLER62V4RREUxTHlM0sHpOnYMwbMMQeM9+qLgkomlUGpUVkjby5btMmGHCl9DFdTYOavUNJ3LuXv0sobg==|oZGZsgOMDe5oaMrE|06|3',
'sec-ch-ua-mobile': '?0',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36',
'Content-Type': 'application/json',
'X-API-SOURCE': 'pc',
'Accept': 'application/json',
'X-Shopee-Language': 'zh-Hans',
'X-Requested-With': 'XMLHttpRequest',
'af-ac-enc-dat': 'AAcyLjQuMS0yAAABhE3Hy6UAAAtLAkIAAAAAAAAAAOYyhFAbVQMMpIKa2+dGIBkKaWUVkWOzjLDykZY2dhCO2aemll6zSawP7dqKio0tSXU8mzeKLk1kA/WyNZ3Ie5A5Nt4iJ1W9aNhMRfWeQ7v8d9m7rMmAzdpxzPCKsKZUt89X1xFf0TvL/NsDCZSiE3F0ERsJBPsctX1CYA4baakfSx+Mbik3yDbxzfoZ9uXVS6oq2etzh1XniTb6mLKOF6kwSZbxI4FnzTS4k+XtcD7yPyi9O9arrEYGHKDT1AgxhDj+TLRcJqaQNDvlDA7IiJvpFsgpeHQXx+lEECXlHknmoTTyj/Vn1dcMyFsj0rpApuO6LdYYfR0WvgE2pJEUSvIqWlCgTPpSIKBuWK+C0hzfGe1o4iEHKgzvRydrIs0DhQk1YcG18ylDmIpexxyWlfUaRjfn5DtSUG9QIVLUSI3R8+2Vi3kGkiVgGH5vlT424PFUtNdb+8K1kDEitmBAZRnJhX2FvN44sM3YZnxNQDhfDc5iLQNlRwi12gPtyiO0aJ0u0EHc6LpdriVstGniIcACAExdmmlMQ+JYTMHF6kF68iRD85aWYi9ro3Wl9b3oSySuEOrDBjHFr5rF050g933uBLbAAhpLfIO+hSPwGUPsJ9/+NzAlsFLDIzfdYGNDP9z6GA2N8G6rj84L/ADQ7yqJhWpZ4w6ktdU1QBJ19JM+JjxlMGGa5/CKeBxPVMGF0rhbVQGRY7OMsPKRljZ2EI7Zp6aWkWOzjLDykZY2dhCO2aemlhn+1ZL5DKAyhUWhwsV2anPVK717vjBfA5ZAs0C9mW0Z',
'X-CSRFToken': 'IDq3287GJnXS5JJj5c2p5NfuvByGNpst',
'sec-ch-ua-platform': '"Windows"',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
'host': 'shopee.com.my',
'Cookie': 'REC_T_ID=99d3d94f-5df0-11ed-b735-2cea7fa8daa9; SPC_F=w4AfWBkq1JrakV2jppFicIhTClRLblU7; SPC_R_T_ID=UXubTQvc/YPsM6xl+teVYis0dA2qLMfX6XkESPWMhmcIFaEi8LrMjdy7JotmJURfc8VtNc6ecvjQ5h0QxzshCQkSOwSRbEYbPzopwt27ggZispI0Ud4iKQQFka+NykFRJH0vM8M04lQUpSa5SxdHmdirR2k7laqgj3MTGLHCqTQ=; SPC_R_T_IV=R0Y1N1IwUUFYa1VqTjJRTw==; SPC_SI=m5xjYwAAAABKQ2FmemF6RlFAiQAAAAAARjNNa3hrdEw=; SPC_T_ID=UXubTQvc/YPsM6xl+teVYis0dA2qLMfX6XkESPWMhmcIFaEi8LrMjdy7JotmJURfc8VtNc6ecvjQ5h0QxzshCQkSOwSRbEYbPzopwt27ggZispI0Ud4iKQQFka+NykFRJH0vM8M04lQUpSa5SxdHmdirR2k7laqgj3MTGLHCqTQ=; SPC_T_IV=R0Y1N1IwUUFYa1VqTjJRTw=='
}
conn.request("GET", "/api/v4/item/get?itemid=9037931641&shopid=41985388", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8")) |