getfqbook.py 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import requests
  2. from urllib.parse import urlencode
  3. def html(url, headers=None, post_data=None):
  4. try:
  5. if post_data:
  6. if isinstance(post_data, dict):
  7. response = requests.post(url, headers=headers, data=urlencode(post_data), allow_redirects=True, verify=False, timeout=(10, 30))
  8. else:
  9. response = requests.post(url, headers=headers, data=post_data, allow_redirects=True, verify=False, timeout=(10, 30))
  10. else:
  11. response = requests.get(url, headers=headers, allow_redirects=True, verify=False, timeout=(10, 30))
  12. return {
  13. 'header': str(response.headers),
  14. 'body': response.text,
  15. 'http_code': response.status_code
  16. }
  17. except Exception as e:
  18. return {
  19. 'header': '',
  20. 'body': str(e),
  21. 'http_code': 0
  22. }
  23. def main():
  24. key = 'PHVJKLVWRUY' # Get this from your input method
  25. if not key:
  26. return
  27. 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"
  28. headers = {
  29. 'Connection': 'keep-alive',
  30. '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',
  31. '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',
  32. 'Content-Type': 'application/json',
  33. 'Referer': 'https://tmaservice.developer.toutiao.com/?appid=tt1b316d8c8401e42101&version=2.3.0'
  34. }
  35. response = html(url, headers)
  36. import json
  37. print(json.loads(response['body']))
  38. if __name__ == "__main__":
  39. main()