douyin_live.py 541 B

12345678910111213141516171819202122
  1. import requests
  2. import re
  3. class douYinLive:
  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 parse(self, html):
  10. return re.findall('flv_pull_url":(.*?})', html)[0]
  11. def start(self):
  12. res = requests.get(self.url, headers=self.headers)
  13. print(self.parse(res.text))
  14. if __name__ == '__main__':
  15. douYinLive().start()