| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #!/usr/bin/env python
- # -*- encoding: utf-8 -*-
- """
- ---------------------------------------
- # @Project : DAGASI
- # @File : fanbox.py
- # @Author : GrayZhao
- # @Date : 2023/2/20 16:25
- # @Version :
- # @Description :
- ---------------------------------------
- """
- import requests
- URL = "https://api.fanbox.cc/post.listTagged?tag=高画質MP4&userId=1549213"
- HEADER = {
- "origin": "https://dagasi.fanbox.cc",
- "referer": "https://dagasi.fanbox.cc/",
- "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"
- }
- class FanboxID:
- """获取作者在 fanbox 中的作品ID"""
- @classmethod
- def __get_fanbox_json(cls, url: str):
- response = requests.get(url=url, headers=HEADER)
- _json = response.json()
- return _json
- @classmethod
- def iterator(cls):
- nextUrl = URL
- while nextUrl:
- data_json = cls.__get_fanbox_json(nextUrl)
- nextUrl = data_json["body"]["nextUrl"]
- items = data_json["body"]["items"]
- for item in items:
- yield item["id"]
- if __name__ == '__main__':
- for index, _id in enumerate(FanboxID.iterator()):
- print(index, _id)
|