main.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # -*- coding: utf-8 -*-
  2. import requests
  3. import pyquery
  4. from bs4 import BeautifulSoup
  5. from pyquery import PyQuery
  6. # 化学
  7. link1 = "https://mp.zhizhuma.com/q?c=120FFM3CB61&sh=sh&vt_=1617104397023&_loginTime=1617104400644"
  8. # 生物
  9. line2 = "https://mp.zhizhuma.com/q?c=120FFM55995&sh=sh&vt_=1617111615643"
  10. # 物理
  11. line3 = "https://mp.zhizhuma.com/q?c=120FFM2RE19&sh=sh&vt_=1617111788726"
  12. prefix = "https://mp.zhizhuma.com"
  13. def start():
  14. resp = requests.get(line3)
  15. # print(resp.text)
  16. soup = BeautifulSoup(resp.text, features="html5lib")
  17. items = soup.select(".chapter-item .sections .section-wrapper")
  18. # print(len(items))
  19. for item in items:
  20. suburl = prefix + item["val"]
  21. title = item.select_one(".section .text").get_text()
  22. subresp = requests.get(suburl)
  23. subsoup = BeautifulSoup(subresp.text, features="html5lib")
  24. m3u8 = subsoup.select_one("#data_content").get_text()
  25. print(title + "," + m3u8)
  26. with open("huaxue.txt", mode="a") as f:
  27. f.write(title + "," + m3u8)
  28. # TODO 调用cli
  29. if __name__ == '__main__':
  30. start()