fanbox.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. """
  4. ---------------------------------------
  5. # @Project : DAGASI
  6. # @File : fanbox.py
  7. # @Author : GrayZhao
  8. # @Date : 2023/2/20 16:25
  9. # @Version :
  10. # @Description :
  11. ---------------------------------------
  12. """
  13. import requests
  14. URL = "https://api.fanbox.cc/post.listTagged?tag=高画質MP4&userId=1549213"
  15. HEADER = {
  16. "origin": "https://dagasi.fanbox.cc",
  17. "referer": "https://dagasi.fanbox.cc/",
  18. "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
  19. }
  20. class FanboxID:
  21. """获取作者在 fanbox 中的作品ID"""
  22. @classmethod
  23. def __get_fanbox_json(cls, url: str):
  24. response = requests.get(url=url, headers=HEADER)
  25. _json = response.json()
  26. return _json
  27. @classmethod
  28. def iterator(cls):
  29. nextUrl = URL
  30. while nextUrl:
  31. data_json = cls.__get_fanbox_json(nextUrl)
  32. nextUrl = data_json["body"]["nextUrl"]
  33. items = data_json["body"]["items"]
  34. for item in items:
  35. yield item["id"]
  36. if __name__ == '__main__':
  37. for index, _id in enumerate(FanboxID.iterator()):
  38. print(index, _id)