import json
from urllib.parse import urlencode
import requests
req_type = "douyin_web_xhr"
headers = {
"User-Agent": "ApiWebServerUser",
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json;charset=UTF-8",
}
api_url = "https://api.addcoder.com/" + req_type
req_params = {"api_auth_key": "601137664d318ffde7c095381db55434"}
params = {
"device_platform": "webapp",
"aid": "6383",
"cookie_enabled": "true",
"platform": "PC",
"downlink": "5.3",
"keyword": "天才小熊猫",
"count": "10",
"offset": 0,
}
req_data = {
"url": "https://www.douyin.com/aweme/v1/web/discover/search/?" + urlencode(params),
"method": "GET",
}
response = requests.post(
api_url,
headers=headers,
params=req_params,
data=json.dumps(req_data, separators=(",", ":")),
timeout=20,
)
print(response.text)