Skip to content

API List

Note

🟢 Indicates implemented, 🟡 Indicates in progress or being modified, 🟤 Indicates temporarily not implemented, 🔵 Indicates possible future implementation, 🔴 Indicates deprecation.

handler API List
CLI InterfaceMethod
Download a Single Weibohandle_one_weibo
Download User's Weibohandle_user_weibo
Data Methods APIMethodDeveloper API
Create User Record & Directoryget_or_add_user_data🟢
Get User Info (UID)fetch_user_info🟢
Get User Info (Screen Name)fetch_user_info_by_screen_name🟢
Get User Detailsfetch_user_detail🟢
Extract Weibo User IDextract_weibo_uid🟢
Fetch Single Weibo Datafetch_one_weibo🟢
Fetch User Weibo Datafetch_user_weibo🟢
utils API List
Utility APIClass NameMethodStatus
Manage Client ConfigClientConfManager🟢
Generate Visitor CookieVisitorManagergen_visitor🟢
Extract Weibo IDWeiboIdFetcherget_weibo_id🟢
Extract All Weibo IDsWeiboIdFetcherget_all_weibo_id🟢
Extract Weibo User IDWeiboUidFetcherget_weibo_uid🟢
Extract All Weibo User IDsWeiboUidFetcherget_all_weibo_uid🟢
Extract Weibo User Screen NameWeiboScreenNameFetcherget_weibo_screen_name🟢
Extract All Weibo User Screen NamesWeiboScreenNameFetcherget_all_weibo_screen_name🟢
Global File Name Formatter-format_file_name🟢
Create User Directory-create_user_folder🟢
Rename User Directory-rename_user_folder🟢
Create or Rename User Directory-create_or_rename_user_folder🟢
Extract Weibo Content-extract_desc🟢
crawler API List
Crawler URL APIClass NameMethodStatus
User Info APIWeiboCrawlerfetch_user_info🟢
User Details APIWeiboCrawlerfetch_user_detail🟢
User Weibo APIWeiboCrawlerfetch_user_weibo🟢
Single Weibo APIWeiboCrawlerfetch_weibo_detail🟢
dl API List
Downloader APIClass NameMethodStatus
Create Download TaskWeiboDownloadercreate_download_task🟢
Handle Download TaskWeiboDownloaderhandler_download🟢
Download ContentWeiboDownloaderdownload_desc🟢
Download VideoWeiboDownloaderdownload_video🟢
Download Image GalleryWeiboDownloaderdownload_images🟢

💡 Tips

  • Pagination parameters are included in the previous request data and can be conveniently filtered using the built-in filter function.
  • All APIs with pagination use asynchronous generator methods, requiring async for iteration for automatic pagination handling.
  • When max_counts is set to None or omitted, all available Weibo data will be fetched.
  • Easily integrates with backend frameworks such as FastAPI, Flask, and Django.
  • Using a logged-in cookie can bypass privacy settings of the account.

handler API List

Create User Record & Directory 🟢

Asynchronous method to retrieve or create user data while also generating a user directory.

ParameterTypeDescription
kwargsdictCLI dictionary data, requires path parameter
user_idstrUser ID
dbAsyncUserDBUser database
ReturnsTypeDescription
user_pathPathUser directory path object
py
import asyncio
from f2.apps.weibo.handler import WeiboHandler
from f2.apps.weibo.db import AsyncUserDB
from f2.log.logger import logger


kwargs = {
    "headers": {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0",
        "Referer": "https://www.weibo.com/",
    },
    "proxies": {"http://": None, "https://": None},
    "cookie": "YOUR_COOKIE_HERE",
    "path": "Download",
    # "mode": "post",
}


async def main():
    async with AsyncUserDB("weibo_users.db") as audb:
        uid = "6524978930"
        logger.info(
            await WeiboHandler(kwargs).get_or_add_user_data(
                kwargs=kwargs, uid=uid, db=audb
            )
        )


if __name__ == "__main__":
    asyncio.run(main())

💡 Tips

  • This is a CLI mode interface, developers can define their own user directory creation functionality.
  • If mode is not set, it defaults to the PLEASE_SETUP_MODE directory.

Fetch User Info (UID) 🟢

Asynchronous method to retrieve user information by UID.

ParameterTypeDescription
uidstrUser ID
ReturnsTypeDescription
UserInfoFilterJsonModelUser information filter containing _to_raw, _to_dict methods
py
import asyncio
from f2.apps.weibo.handler import WeiboHandler
from f2.log.logger import logger


kwargs = {
    "headers": {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0",
        "Referer": "https://www.weibo.com/",
    },
    "proxies": {"http://": None, "https://": None},
    "cookie": "YOUR_COOKIE_HERE",
}


async def main():
    user = await WeiboHandler(kwargs).fetch_user_info(uid="2265830070")
    # logger.info(
    #     f"微博用户ID: {user.uid}, 昵称: {user.nickname}, 性别: {user.gender}, 地区: {user.location}, 关注数: {user.friends_count}, 粉丝数: {user.followers_count}, 微博数: {user.weibo_count}, 个人主页: {user.profile_url}"
    # )
    logger.info("=================_to_raw================")
    logger.info(user._to_raw())
    # logger.info("=================_to_dict===============")
    # logger.info(user._to_dict())


if __name__ == "__main__":
    asyncio.run(main())

Fetch User Info (Screen Name) 🟢

Asynchronous method to retrieve user information by screen name.

ParameterTypeDescription
screen_namestrUser screen name
ReturnsTypeDescription
UserInfoFilterJsonModelUser information filter containing _to_raw, _to_dict methods
py
import asyncio
from f2.apps.weibo.handler import WeiboHandler
from f2.log.logger import logger


kwargs = {
    "headers": {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0",
        "Referer": "https://www.weibo.com/",
    },
    "proxies": {"http://": None, "https://": None},
    "cookie": "YOUR_COOKIE_HERE",
}


async def main():
    user = await WeiboHandler(kwargs).fetch_user_info_by_screen_name(
        screen_name="阿里多多酱"
    )
    # logger.info(
    #     f"微博用户ID: {user.uid}, 昵称: {user.nickname}, 性别: {user.gender}, 地区: {user.location}, 关注数: {user.friends_count}, 粉丝数: {user.followers_count}, 微博数: {user.weibo_count}, 个人主页: {user.profile_url}"
    # )
    logger.info("=================_to_raw================")
    logger.info(user._to_raw())
    # logger.info("=================_to_dict===============")
    # logger.info(user._to_dict())


if __name__ == "__main__":
    asyncio.run(main())

Fetch User Details 🟢

Asynchronous method to retrieve detailed user information.

ParameterTypeDescription
uidstrUser ID
ReturnsTypeDescription
UserDetailFilterJsonModelUser detail filter containing _to_raw, _to_dict methods
py
import asyncio
from f2.apps.weibo.handler import WeiboHandler
from f2.log.logger import logger


kwargs = {
    "headers": {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0",
        "Referer": "https://www.weibo.com/",
    },
    "proxies": {"http://": None, "https://": None},
    "cookie": "YOUR_COOKIE_HERE",
}


async def main():
    user = await WeiboHandler(kwargs).fetch_user_detail(uid="2265830070")
    # logger.info(
    #     f"用户ID: {uid}, 生日: {user.birthday}, 性别: {user.gender}, 地区: {user.location}, 个性签名: {user.description_raw}, 注册时间: {user.create_at}, 视频播放次数: {user.video_play_count}"
    # )
    logger.info("=================_to_raw================")
    logger.info(user._to_raw())
    # logger.info("=================_to_dict===============")
    # logger.info(user._to_dict())


if __name__ == "__main__":
    asyncio.run(main())

Extract Weibo User ID 🟢

Asynchronous method to extract and return user ID from a Weibo link.

ParameterTypeDescription
urlstrWeibo link
ReturnsTypeDescription
uidstrUser ID
py
import asyncio
from f2.apps.weibo.handler import WeiboHandler
from f2.log.logger import logger

kwargs = {
    "headers": {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0",
        "Referer": "https://www.weibo.com/",
    },
    "proxies": {"http://": None, "https://": None},
}


async def main():
    uid = await WeiboHandler(kwargs).extract_weibo_uid(
        url="https://weibo.com/u/2265830070"
    )
    logger.info(f"微博用户ID: {uid}")


if __name__ == "__main__":
    asyncio.run(main())

Fetch Single Weibo Data 🟢

Asynchronous method to retrieve a single Weibo post's data.

ParameterTypeDescription
weibo_idstrWeibo ID
ReturnsTypeDescription
WeiboDetailFilterJsonModelWeibo detail filter containing _to_raw, _to_dict methods
py
import asyncio
from f2.apps.weibo.handler import WeiboHandler
from f2.log.logger import logger


kwargs = {
    "headers": {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0",
        "Referer": "https://www.weibo.com/",
    },
    "proxies": {"http://": None, "https://": None},
    "cookie": "YOUR_COOKIE_HERE",
}


async def main():
    weibo = await WeiboHandler(kwargs).fetch_one_weibo(weibo_id="O8DM0BLLm")
    # logger.info(
    #     f"微博ID: {weibo.weibo_id}, 微博文案: {weibo.desc}, 作者昵称: {weibo.nickname}, 发布时间: {weibo.weibo_created_at}"
    # )
    logger.info("=================_to_raw================")
    logger.info(weibo._to_raw())
    # logger.info("=================_to_dict===============")
    # logger.info(weibo._to_dict())


if __name__ == "__main__":
    asyncio.run(main())

Fetch User Weibo Data 🟢

Asynchronous method to retrieve a user's Weibo posts.

ParameterTypeDescription
uidstrUser ID
pageintPage number
featureintWeibo type
since_idstrStarting Weibo ID
max_countsintMaximum number of Weibo posts
ReturnsTypeDescription
UserWeiboFilterJsonModelUser Weibo filter containing _to_raw, _to_dict methods
py
import asyncio
from f2.apps.weibo.handler import WeiboHandler
from f2.log.logger import logger


kwargs = {
    "headers": {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0",
        "Referer": "https://www.weibo.com/",
    },
    "proxies": {"http://": None, "https://": None},
    "cookie": "YOUR_COOKIE_HERE",
}


async def main():
    async for weibo_list in WeiboHandler(kwargs).fetch_user_weibo(
        uid="2265830070",
        page=1,
        feature=1,
        since_id="",
        max_counts=20,
    ):
        # logger.info(
        #     f"微博ID: {weibo_list.weibo_id}, 微博文案: {weibo_list.weibo_desc_raw}, 作者昵称: {weibo_list.weibo_user_name_raw}, 发布时间: {weibo_list.weibo_created_at}"
        # )
        logger.info("=================_to_raw================")
        logger.info(weibo_list._to_raw())
        # logger.info("=================_to_dict===============")
        # logger.info(weibo_list._to_dict())
        # logger.info("=================_to_list===============")
        # logger.info(weibo_list._to_list())


if __name__ == "__main__":
    asyncio.run(main())

utils API List

Manage Client Configuration 🟢

Class method for managing client configuration.

ParameterTypeDescription
NoneNoneNone
ReturnTypeDescription
Config ValueAnyConfiguration file value
py
from f2.apps.weibo.utils import ClientConfManager

if __name__ == "__main__":
    print("Client Configuration:")
    print(ClientConfManager.client())

    print("Client Configuration version:")
    print(ClientConfManager.conf_version())

    print("Client Configuration user-agent:")
    print(ClientConfManager.user_agent())

Class method for generating a visitor cookie.

ParameterTypeDescription
NoneNoneNone
ReturnTypeDescription
visitor_cookiestrVisitor Cookie
py
import asyncio
from f2.apps.weibo.utils import VisitorManager
from f2.log.logger import logger


async def main():
    visitor_cookie = await VisitorManager.gen_visitor()
    logger.info(f"visitor_cookie: {visitor_cookie}")


if __name__ == "__main__":
    asyncio.run(main())

Extract Weibo ID 🟢

Class method to extract a Weibo ID from a Weibo URL.

ParameterTypeDescription
urlstrWeibo link
ReturnTypeDescription
weibo_idstrWeibo ID
py
import asyncio
from f2.apps.weibo.utils import WeiboIdFetcher
from f2.log.logger import logger


async def main():
    raw_url = "https://weibo.com/2265830070/O8DM0BLLm"
    return await WeiboIdFetcher.get_weibo_id(raw_url)


if __name__ == "__main__":
    logger.info(asyncio.run(main()))

Extract Multiple Weibo IDs 🟢

Class method to extract multiple Weibo IDs from a list of Weibo URLs.

ParameterTypeDescription
urlsList[str]List of Weibo links
ReturnTypeDescription
weibo_idsList[str]List of Weibo IDs
py
import asyncio
from f2.apps.weibo.utils import WeiboIdFetcher
from f2.utils.utils import extract_valid_urls
from f2.log.logger import logger


async def main():
    raw_urls = [
        "https://weibo.com/2265830070/O8DM0BLLm",
        "https://weibo.com/2265830070/O8DM0BLLm/",
        "https://weibo.com/2265830070/O8DM0BLLm/aasfasg",
        "https://weibo.com/2265830070/O8DM0BLLm/?test=123",
        "https://weibo.cn/2265830070/O8DM0BLLm/",
        "https://weibo.cn/status/5020595169001740/?test=123",
        "https://www.weibo.com/2265830070/5020595169001740",
    ]

    # 提取有效URL
    urls = extract_valid_urls(raw_urls)

    # 对于URL列表
    return await WeiboIdFetcher.get_all_weibo_id(urls)


if __name__ == "__main__":
    logger.info(asyncio.run(main()))

Extract Weibo User ID 🟢

Class method to extract a Weibo user ID from a Weibo profile URL.

ParameterTypeDescription
urlstrWeibo profile link
ReturnTypeDescription
uidstrUser ID
py
import asyncio
from f2.apps.weibo.utils import WeiboUidFetcher
from f2.log.logger import logger


async def main():
    raw_url = "https://weibo.com/u/2265830070"
    return await WeiboUidFetcher.get_weibo_uid(raw_url)


if __name__ == "__main__":
    logger.info(asyncio.run(main()))

❕ Tip

  • The extract_weibo_uid method in the data interface can more comprehensively process Weibo URLs. However, this method is only applicable for non-nickname-based URLs.

Extract Multiple Weibo User IDs 🟢

Class method to extract multiple Weibo user IDs from a list of Weibo profile URLs.

ParameterTypeDescription
urlsList[str]List of Weibo profile links
ReturnTypeDescription
uidsList[str]List of User IDs
py
import asyncio
from f2.apps.weibo.utils import WeiboUidFetcher
from f2.utils.utils import extract_valid_urls
from f2.log.logger import logger


async def main():
    raw_urls = [
        "https://weibo.com/u/2265830070",
        "https://weibo.com/u/2265830070/",
        "https://weibo.com/u/2265830070/?test=123",
        "https://weibo.com/2265830070",
        "https://weibo.com/2265830070/",
        "https://weibo.com/2265830070/?test=123",
        "https://weibo.com/2265830070/O8DM0BLLm",
        "https://weibo.com/2265830070/O8DM0BLLm/",
        "https://weibo.com/2265830070/O8DM0BLLm/?test=123",
        "https://weibo.com/2265830070/O8DM0BLLm/%$#",
        "https://weibo.com/2265830070/O8DM0BLLm/" + "a" * 2048,
        "https://m.weibo.cn/2265830070/5020595169001740",
        "https://m.weibo.cn/2265830070/5020595169001740?test=123",
        "https://m.weibo.cn/2265830070/5020595169001740/",
        "https://m.weibo.cn/2265830070/5020595169001740/?test=123",
    ]

    # 提取有效URL
    urls = extract_valid_urls(raw_urls)

    # 对于URL列表
    return await WeiboUidFetcher.get_all_weibo_uid(urls)


if __name__ == "__main__":
    logger.info(asyncio.run(main()))

Extract Weibo Username 🟢

Class method to extract a Weibo username from a Weibo profile URL.

ParameterTypeDescription
urlstrWeibo profile link
ReturnTypeDescription
screen_namestrUsername
py
import asyncio
from f2.apps.weibo.utils import WeiboScreenNameFetcher
from f2.log.logger import logger


async def main():
    raw_url = "https://weibo.com/n/自我充电功能丧失"
    return await WeiboScreenNameFetcher.get_weibo_screen_name(raw_url)


if __name__ == "__main__":
    logger.info(asyncio.run(main()))

Extract Multiple Weibo Usernames 🟢

Class method to extract multiple Weibo usernames from a list of Weibo profile URLs.

ParameterTypeDescription
urlsList[str]List of Weibo profile links
ReturnTypeDescription
screen_namesList[str]List of Usernames
py
import asyncio
from f2.apps.weibo.utils import WeiboScreenNameFetcher
from f2.utils.utils import extract_valid_urls
from f2.log.logger import logger


async def main():
    raw_urls = [
        "https://weibo.com/n/%E8%87%AA%E6%88%91%E5%85%85%E7%94%B5%E5%8A%9F%E8%83%BD%E4%B8%A7%E5%A4%B1",
        "https://weibo.com/n/%E8%87%AA%E6%88%91%E5%85%85%E7%94%B5%E5%8A%9F%E8%83%BD%E4%B8%A7%E5%A4%B1/",
        "https://weibo.com/n/%E8%87%AA%E6%88%91%E5%85%85%E7%94%B5%E5%8A%9F%E8%83%BD%E4%B8%A7%E5%A4%B1?test=123",
        "https://weibo.com/n/%E8%87%AA%E6%88%91%E5%85%85%E7%94%B5%E5%8A%9F%E8%83%BD%E4%B8%A7%E5%A4%B1/?test=123",
        "https://weibo.com/n/自我充电功能丧失",
        "https://weibo.com/n/自我充电功能丧失/",
        "https://weibo.com/n/自我充电功能丧失?test=123",
        "https://weibo.com/n/自我充电功能丧失/?test=123",
    ]

    # 提取有效URL
    urls = extract_valid_urls(raw_urls)

    # 对于URL列表
    return await WeiboScreenNameFetcher.get_all_weibo_screen_name(urls)


if __name__ == "__main__":
    logger.info(asyncio.run(main()))

ℹ️ Tip

F2 automatically handles encoding, so you don't have to worry about escaping Chinese characters.

Global File Name Formatting 🟢

Formats filenames globally based on the configuration file.

📄 Filename Formatting Rules
  • Windows filename length limit: 255 characters; with long filename support, up to 32,767 characters.
  • Unix filename length limit: 255 characters.
  • Extracts 20 characters from the cleaned name and appends the suffix, ensuring it generally does not exceed 255 characters.
  • Developers can define custom fields in custom_fields to generate custom filenames.
ParameterTypeDescription
naming_templatestrFile naming template
weibo_datadictDictionary of Weibo post data
custom_fieldsdictUser-defined fields for replacing default values
ReturnTypeDescription
file_namestrFormatted file name
py
import asyncio
from f2.apps.weibo.handler import WeiboHandler
from f2.apps.weibo.utils import format_file_name


async def main():
    # 文件名模板
    kwargs = {
        "headers": {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0",
            "Referer": "https://www.weibo.com/",
        },
        "naming": "{create}_{desc}_{weibo_id}",
        "cookie": "YOUR_COOKIE_HERE",
    }
    # 单作品的数据
    weibo_data = await WeiboHandler(kwargs).fetch_one_weibo(weibo_id="LvFY288c0")
    # 格式化后的文件名
    print(format_file_name(kwargs.get("naming"), weibo_data._to_dict()) + "_weibo")

    # 文件名模板
    kwargs = {
        # ...
        "naming": "{create}_{desc}_{weibo_id}_{location}",
        # ...
    }
    # 用户自定义字段
    custom_fields = {"location": "Guang dong"}
    # 格式化后的自定义文件名
    print(
        format_file_name(kwargs.get("naming"), weibo_data._to_dict(), custom_fields)
        + "_weibo"
    )


if __name__ == "__main__":
    asyncio.run(main())

Create User Directory 🟢

Creates a user directory if it does not already exist.

📂 User Directory Structure

If no path is specified in the configuration file, the default directory is Download. Both absolute and relative paths are supported.

bash
├── Download
   ├── weibo
   ├── post
   ├── user_nickname
   ├── 2023-12-31_23-59-59_desc
   ├── 2023-12-31_23-59-59_desc-video.mp4
   ├── 2023-12-31_23-59-59_desc-desc.txt
   └── 2023-12-31_23-59-59_desc-cover.jpg
   └── ......
   ├── like
   ├── ...
ParameterTypeDescription
kwargsdictCLI configuration file
nicknameUnion[str, int]User nickname
ReturnTypeDescription
user_pathPathUser directory path object
py
from f2.apps.weibo.utils import create_user_folder


kwargs = {
    "headers": {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0",
        "Referer": "https://www.weibo.com/",
    },
    "proxies": {"http": None, "https": None},
    "cookie": "YOUR_COOKIE_HERE",
    "path": "Download",
    "mode": "post",
}


if __name__ == "__main__":
    current_nickname = "New Nickname"
    print(create_user_folder(kwargs, current_nickname))
    # X:\......\Download\weibo\post\New Nickname

Rename User Directory 🟢

Used to rename a user directory.

ParameterTypeDescription
old_pathPathOld user directory path object
new_nicknamestrNew user nickname
ReturnTypeDescription
new_pathPathNew user directory path object
py
import asyncio
from f2.apps.weibo.db import AsyncUserDB
from f2.apps.weibo.utils import rename_user_folder
from f2.apps.weibo.handler import WeiboHandler


kwargs = {
    "headers": {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0",
        "Referer": "https://www.weibo.com/",
    },
    "proxies": {"http://": None, "https://": None},
    "cookie": "YOUR_COOKIE_HERE",
    "path": "Download",
    "mode": "post",
}


async def main():
    uid = "2265830070"
    async with AsyncUserDB("weibo_users.db") as audb:
        local_user_path = await WeiboHandler(kwargs).get_or_add_user_data(
            kwargs, uid, audb
        )
    print(local_user_path)
    # X:\......\Download\weibo\post\阿里多多酱

    current_nickname = "New Nickname"
    new_user_path = rename_user_folder(local_user_path, current_nickname)
    print(new_user_path)
    # X:\......\Download\weibo\post\New Nickname


if __name__ == "__main__":
    asyncio.run(main())

💡 Tip

If the directory does not exist, it will first create the user directory before renaming it.

Create or Rename User Directory 🟢

Used to create or rename a user directory. It combines the two interfaces above.

ParameterTypeDescription
kwargsdictCLI configuration file
local_user_datadictLocal user data
current_nicknamestrCurrent user nickname
ReturnTypeDescription
user_pathPathUser directory path object

ℹ️ Tip

This interface effectively solves the problem of duplicate directory creation when users rename themselves. It is integrated into the handler interface. Developers do not need to worry about it; they can directly call the data interface of handler.

Extract Weibo Text 🟢

Used to extract Weibo text while excluding the final link.

ParameterTypeDescription
textstrWeibo text
ReturnTypeDescription
textstrExtracted Weibo text
py
from f2.apps.weibo.utils import extract_desc
from f2.log.logger import logger


def main():
    raw_desc = {
        "超大颗花生汤圆[舔屏] http://t.cn/A6nqzsFe",
        "分享视频 http://t.cn/A6nNyQyS ​​​",
        "香宝宝   http://t.cn/A6mwArY7 ​​​",
        "  总有人类想要变成小猫咪^⌯𖥦⌯^ ੭   http://t.cn/A6n1zhGt ​​​",
        "过来挨踢[亲亲]      http://t.cn/A6ndh6PS ​​​",
        "单独的文案   ",  # 没有链接的情况
        "http://t.cn/A6nqzsFe",  # 只有链接的情况
        "   ",  # 空字符串或空白内容
    }

    for text_raw in raw_desc:
        desc = extract_desc(text_raw)
        logger.info(f"提取结果: {desc}")


if __name__ == "__main__":
    main()

Crawler API List

User Information API 🟢

Used to retrieve user information.

ParameterTypeDescription
paramsUserInfoUser information API model
ReturnTypeDescription
_fetch_get_jsondictUser information data

User Details API 🟢

Used to retrieve user details.

ParameterTypeDescription
paramsUserDetailUser details API model
ReturnTypeDescription
_fetch_get_jsondictUser details data

User Weibo API 🟢

Used to retrieve a user's Weibo posts.

ParameterTypeDescription
paramsUserWeiboUser Weibo API model
ReturnTypeDescription
_fetch_get_jsondictUser Weibo data

Single Weibo API 🟢

Used to retrieve a single Weibo post.

ParameterTypeDescription
paramsWeiboDetailSingle Weibo API model
ReturnTypeDescription
_fetch_get_jsondictSingle Weibo data

DL API List

Create Download Task 🟢

Process Download Task 🟢

Download Text 🟢

Download Video 🟢

Released under the Apache-2.0 license.