import requests from urllib.parse import urlencode def html(url, headers=None, post_data=None): try: if post_data: if isinstance(post_data, dict): response = requests.post(url, headers=headers, data=urlencode(post_data), allow_redirects=True, verify=False, timeout=(10, 30)) else: response = requests.post(url, headers=headers, data=post_data, allow_redirects=True, verify=False, timeout=(10, 30)) else: response = requests.get(url, headers=headers, allow_redirects=True, verify=False, timeout=(10, 30)) return { 'header': str(response.headers), 'body': response.text, 'http_code': response.status_code } except Exception as e: return { 'header': '', 'body': str(e), 'http_code': 0 } def main(): key = 'PHVJKLVWRUY' # Get this from your input method if not key: return url = f"https://api.whbfxb.cn/api/novelsale/reader/get/content/v1/?aid=40013183&device_brand=realme&device_platform=android&device_type=RMX2020&mp_sdk_version=3.21.0&novelsale_app_scene=023001&version_code=230&key={key}&item_source=1&module_name=ad_link&click_id=__CLICKID__&clickid=__CLICKID__&creativetype=__CTYPE__&demand_id=0&item_id=&media_source=1&mid1=__MID1__&mid2=__MID2__&mid3=__MID3__&mid4=__MID4__&mid5=__MID5__&projectid=__PROJECT_ID__&promotionid=__PROMOTION_ID__&request_id=__REQUESTID__&book_id=&host_novelsale_app_id=40013183" headers = { 'Connection': 'keep-alive', 'Cookie': 'sid_tt=617946caef227c4a80e1dd9cb290515e;ssid_ucp_v1=1.0.0-KGY3OGU0YWM0OTMzMjI1YTg4OThiMTAyMGI3YmFhOTIxNjE2YzZiYzQKFQjkktCcvMz_ARCf9PC5Bhjv6CA4CBoCaGwiIDYxNzk0NmNhZWYyMjdjNGE4MGUxZGQ5Y2IyOTA1MTVl;is_staff_user=false;sid_ucp_v1=1.0.0-KGY3OGU0YWM0OTMzMjI1YTg4OThiMTAyMGI3YmFhOTIxNjE2YzZiYzQKFQjkktCcvMz_ARCf9PC5Bhjv6CA4CBoCaGwiIDYxNzk0NmNhZWYyMjdjNGE4MGUxZGQ5Y2IyOTA1MTVl;sessionid=617946caef227c4a80e1dd9cb290515e;ttwid=1%7CG17ZXFInuaAvJxxf46K8gU7KOBUO5aC89gBmDvnA_fo%7C1732000431%7C90ea8439ff8c370df5be3f31d7187a23ed8a2318b4a1aa7d345283ba395bfcb2;sessionid_ss=617946caef227c4a80e1dd9cb290515e;sid_guard=617946caef227c4a80e1dd9cb290515e%7C1732000287%7C5184000%7CSat%2C+18-Jan-2025+07%3A11%3A27+GMT;uid_tt=560968d5ca0089cc8ce610b12f7f2191;passport_csrf_token=8a66478b232599457f588305cb6317dd;uid_tt_ss=560968d5ca0089cc8ce610b12f7f2191;odin_tt=38b1a8591565cfabfde8e2ff37a2d033e74a58e85a42dbf7c48fbca909ebd43b2a0ef306193946a4c74c64f005d15aaef66f3f0b5fe61669cd56f37b355e1591;passport_csrf_token_default=8a66478b232599457f588305cb6317dd;store-region=cn-gs;store-region-src=uid;n_mh=9-mIeuD4wZnlYrrOvfzG3MuT6aQmCUtmr8FxV8Kl8xY', 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; RMX2020 Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/120.0.6099.193 Mobile Safari/537.36 aweme/29.4.0 ToutiaoMicroApp/3.21.0 PluginVersion/29409006', 'Content-Type': 'application/json', 'Referer': 'https://tmaservice.developer.toutiao.com/?appid=tt1b316d8c8401e42101&version=2.3.0' } response = html(url, headers) import json print(json.loads(response['body'])) if __name__ == "__main__": main()