python 根据curl 发送请求 data 是空 不知原因
curl -H 'Host: search5-search-hl.amemv.com' -H 'Cookie: install_id=3149415743253336; ttreq=1$cfb4b6f0b2512ee66d17a2b6fb86f9de3cdafbfd; odin_tt=7af55b05162edb3cd29e1a267db48f307d89c31c42c8a9311aec74bf8665340633599d38f7ae0b3483160e76e8de6bcb5d53507a6c4c6f7ac63e79c0e35b76c2' -H 'x-ss-req-ticket: 1611132417759' -H 'sdk-version: 1' -H 'content-type: application/x-www-form-urlencoded; charset=UTF-8' -H 'x-ss-stub: 30915B60DEB762534F922C6B0E25D32E' -H 'x-ss-dp: 1128' -H 'x-tt-trace-id: 00-1ef9b86f09feb4ba0726bdf26a960468-1ef9b86f09feb4ba-01' -H 'user-agent: com.ss.android.ugc.aweme/100201 (Linux; U; Android 9; zh_CN; JKM-AL00b; Build/HUAWEIJKM-AL00b; Cronet/TTNetVersion:79d23018 2020-02-03 QuicVersion:ac58aac6 2020-01-20)' -H 'x-khronos: 1611132417' -H 'x-gorgon: 040140a400006e91c1d55ad6c59b0f8bd64636bc1fd44cead7ec' --data-binary "keyword=secooshanghai&offset=0&count=20&is_pull_refresh=0&search_source=normal_search&hot_search=0&latitude=43.81451794520082&longitude=126.53320859417103&search_id=&query_correct_type=1&mac_address=78%3AF8%3ACC%3AB4%3ACF%3AA1&is_filter_search=0&sort_type=0&publish_time=0&disable_synthesis=0&multi_mod=0&single_filter_aladdin=0&client_width=360&dynamic_type=0&epidemic_card_type=0" --compressed 'https://search5-search-hl.amemv.com/aweme/v1/general/search/single/?manifest_version_code=100201&_rticket=1611132417765&app_type=normal&iid=3149415743253336&channel=360_aweme&device_type=JKM-AL00b&language=zh&uuid=864158044281203&resolution=720*1408&openudid=fc3692787dcb1d88&update_version_code=10209900&cdid=aea1df9e-f02c-4873-b941-75fc060b41ff&os_api=28&dpi=320&ac=wifi&device_id=68372111474&os_version=9&version_code=100200&app_name=aweme&version_name=10.2.0&device_brand=HUAWEI&ssmix=a&device_platform=android&aid=1128&ts=1611132417'
这个curl 放到服务器运行可以出来数据
我用python 发这个请求
import requestsbody='keyword=secooshanghai&offset=0&count=20&is_pull_refresh=0&search_source=normal_search&hot_search=0&latitude=43.81451794520082&longitude=126.53320859417103&search_id=&query_correct_type=1&mac_address=78%3AF8%3ACC%3AB4%3ACF%3AA1&is_filter_search=0&sort_type=0&publish_time=0&disable_synthesis=0&multi_mod=0&single_filter_aladdin=0&client_width=360&dynamic_type=0&epidemic_card_type=0'.split("&")
douyin_url='https://search5-search-hl.amemv.com/aweme/v1/general/search/single/?manifest_version_code=100201&_rticket=1611132417765&app_type=normal&iid=3149415743253336&channel=360_aweme&device_type=JKM-AL00b&language=zh&uuid=864158044281203&resolution=720*1408&openudid=fc3692787dcb1d88&update_version_code=10209900&cdid=aea1df9e-f02c-4873-b941-75fc060b41ff&os_api=28&dpi=320&ac=wifi&device_id=68372111474&os_version=9&version_code=100200&app_name=aweme&version_name=10.2.0&device_brand=HUAWEI&ssmix=a&device_platform=android&aid=1128&ts=1611132417'
headers={"Host":'search5-search-hl.amemv.com',
"Cookie":"install_id=3149415743253336; ttreq=1$cfb4b6f0b2512ee66d17a2b6fb86f9de3cdafbfd; odin_tt=7af55b05162edb3cd29e1a267db48f307d89c31c42c8a9311aec74bf8665340633599d38f7ae0b3483160e76e8de6bcb5d53507a6c4c6f7ac63e79c0e35b76c2",
"x-ss-req-ticket":"1611132417759",
"sdk-version":"1",
"content-type":"application/x-www-form-urlencoded; charset=UTF-8",
"x-ss-stub":"30915B60DEB762534F922C6B0E25D32E",
"x-ss-dp":"1128",
"x-tt-trace-id":"00-1ef9b86f09feb4ba0726bdf26a960468-1ef9b86f09feb4ba-01",
"user-agent":"com.ss.android.ugc.aweme/100201 (Linux; U; Android 9; zh_CN; JKM-AL00b; Build/HUAWEIJKM-AL00b; Cronet/TTNetVersion:79d23018 2020-02-03 QuicVersion:ac58aac6 2020-01-20)",
"x-khronos":"1611132417",
"x-gorgon":"040140a400006e91c1d55ad6c59b0f8bd64636bc1fd44cead7ec"}
data={}
for str in body:
data[str.split('=')[0]]=str.split('=')[1]
print(data)
print(headers)
res=requests.post(url=douyin_url,headers=headers,data=data)
print(res.text)
返回结果
{"status_code":0,"data":[],"qc":"","cursor":0,"has_more":0,"extra":{"now":1611199559000,"logid":"2021012111255901014508216040E7B3E0","fatal_item_ids":[],"search_request_id":""},"log_pb":{"impr_id":"2021012111255901014508216040E7B3E0"},"search_nil_info":{"search_nil_type":"","is_load_more":"first_flush","search_nil_item":"hit_shark","text_type":50},"guide_search_words":null,"global_doodle_config":{"keyword":"secooshanghai"},"backtrace":"mliddjkA37kbl9lUZL4hmJWtIoMWHALGrFl9h9w+O3X8VHBJvUDhtC9AKReiFeECPKy3uLQamHWCVEI3rFvKMgobeElPxvSNE6wAHJM3pyk=","polling_time":3}
正常这里是有返回数据的data[]
以上是 python 根据curl 发送请求 data 是空 不知原因 的全部内容, 来源链接: utcz.com/p/937901.html