好友
阅读权限10
听众
最后登录1970-1-1
|
50吾爱币
需求:
我有几百个抖店商品的链接,现在需要批量爬取这些链接的发货地址;帮忙用python写个源码,谢谢!
目标网址1:
https://haohuo.jinritemai.com/ecommerce/trade/detail/index.html?id=3637205268498149252预计18小时内从广西壮族自治区发货,包邮
目标网址2:
https://haohuo.jinritemai.com/ecommerce/trade/detail/index.html?id=3649120070661209894
广东省48小时内从广东省发货,包邮
目标网址3:未知则显示未知,不显示空
https://haohuo.jinritemai.com/ecommerce/trade/detail/index.html?id=3649120070661209894
48小时内发货,包邮
顺便问一下:
为什么我按下边的写法python报错:{"code":11001,"data":null,"msg":"当前网络不稳定,请稍后再试","st":11001}
目前只有这么多币了,提前感谢
import requests
def send_post_request():
# 设置请求头
headers = {
'Host': 'haohuo.jinritemai.com',
'Connection': 'keep-alive',
'Content-Length': '569',
'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114"',
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/x-www-form-urlencoded',
'sec-ch-ua-mobile': '?0',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.5735.289 Safari/537.36',
'sec-ch-ua-platform': '"Windows"',
'Origin': 'https://haohuo.jinritemai.com',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
'Referer': 'https://haohuo.jinritemai.com/ecommerce/trade/detail/index.html?id=3637205268498149252',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
'Cookie': 'Cookie' # Cookie信息隐藏
}
# 设置请求体参数
data = {
'ui_params': '{"from_live":false,"from_video":null,"three_d_log_data":null,"follow_status":null,"which_account":null,"ad_log_extra":null,"from_group_id":null,"bolt_param":null,"transition_tracker_data":null,"selected_ids":null,"window_reposition":null,"is_short_screen":null,"full_mode":true}', # 完整的ui_params参数
'use_new_price': '1',
'is_h5': '1',
'bff_type': '2',
'is_in_app': '0',
'origin_type': '',
'promotion_ids': '3637205268498149252',
'meta_param': '',
'source_page': '',
'request_additions': '',
'isFromVideo': 'false',
'enable_timing': 'true'
}
url = 'https://haohuo.jinritemai.com/aweme/v2/shop/promotion/pack/h5/?is_h5=1&is_native_h5=1&verifyFp=verify_lpseyl2g_zYR8tlCG_ao5k_47gZ_ALH0_L7E53qfxkYSb&msToken=fu0YIT3vGjWhVrxcaLUv_PSR2Kp7kCjrk_K5pcagI3RjwYxxh59wPXXFJF_Xu01qjEyi2V5-g8IjOeszznyh9-UokGf-nH60sEYD_NPTrH3HeW3L6wG_2hP3nTr5nW0%3D&a_bogus=YJ-EDchgMsR1KEhcKwkz9n9gcbj0YW-DgZEzhY%2F4OzwA'
# 发送POST请求
response = requests.post(url, headers=headers, data=data)
# 打印响应内容
print(response.text)
if __name__ == "__main__":
send_post_request() |
|