AcFun.py 579 B

12345678910111213141516171819202122
  1. import requests
  2. import re
  3. import json
  4. class AcFun:
  5. def __init__(self, url):
  6. self.url = url
  7. self.headers = {
  8. "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36¬"
  9. }
  10. def start(self):
  11. res = requests.get(self.url, headers=self.headers)
  12. json_info = json.loads(re.findall("window.pageInfo =(.*?);", res.text)[0].split("=", 1)[-1].strip())
  13. print(json_info)
  14. return json_info
  15. if __name__ == '__main__':
  16. AcFun().start()