bilibili.py 510 B

123456789101112131415161718192021
  1. import requests
  2. import re
  3. class Bili:
  4. def __init__(self, url):
  5. self.url = url
  6. self.headers = {
  7. "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¬"
  8. }
  9. def start(self):
  10. res = requests.get(self.url)
  11. result = re.findall("window.__playinfo__=(.*?)</script>", res.text)
  12. print(result[0])
  13. return result[0]
  14. if __name__ == '__main__':
  15. Bili().start()