Skip to main content
Glama

get_fans

Retrieve a Weibo user's followers by providing their unique ID, with options to control pagination and limit results for efficient data collection.

Instructions

Get a Weibo user's fans. Returns: list[dict]: List of dictionaries containing fan information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidYesThe unique identifier of the Weibo user
limitNoMaximum number of fans to return, defaults to 15
pageNoPage number for pagination, defaults to 1

Implementation Reference

  • The FastMCP tool handler for 'get_fans', registered via @mcp.tool(). Defines input schema with Annotated Field descriptions for uid, limit, page. Delegates execution to WeiboCrawler.get_fans().
    @mcp.tool() async def get_fans( ctx: Context, uid: Annotated[int, Field(description="The unique identifier of the Weibo user")], limit: Annotated[int, Field(description="Maximum number of fans to return, defaults to 15", default=15)] = 15, page: Annotated[int, Field(description="Page number for pagination, defaults to 1", default=1)] = 1 ) -> list[dict]: """ Get a Weibo user's fans. Returns: list[dict]: List of dictionaries containing fan information """ return await crawler.get_fans(uid, limit, page)
  • Core helper function in WeiboCrawler that implements the logic for fetching a user's fans via Weibo search API using specific containerid for fans, parsing the response cards, and converting users to UserProfile objects.
    async def get_fans(self, uid: int, limit: int = 15, page: int = 1) -> list[UserProfile]: """ Get fans of a specific Weibo user. Args: uid (int): The unique identifier of the Weibo user limit (int): Maximum number of fans to return, defaults to 15 page (int): The page number for pagination, defaults to 1 Returns: list[UserProfile]: List of UserProfile objects containing fan information """ async with httpx.AsyncClient() as client: try: params = { 'containerid': f'231051_-_fans_-_{str(uid)}', 'page': page, } encoded_params = urlencode(params) response = await client.get(f'{SEARCH_URL}?{encoded_params}', headers=DEFAULT_HEADERS) result = response.json() cards = result["data"]["cards"] if len(cards) < 1: return [] else: cardGroup = cards[-1]['card_group'] return [self._to_user_profile(item['user']) for item in cardGroup][:limit] except httpx.HTTPError: self.logger.error(f"Unable to get fans for uid '{str(uid)}'", exc_info=True) return []
  • Pydantic BaseModel UserProfile defining the output structure for each fan returned by get_fans (list[UserProfile]).
    class UserProfile(BaseModel): """ Data model for a Weibo user's profile information. Attributes: id (int): User's unique identifier screen_name (str): User's display name profile_image_url (str): URL to user's profile image profile_url (str): URL to user's Weibo profile page description (str): User's profile description follow_count (int): Number of users the user is following followers_count (str): Number of followers (as string) avatar_hd (str): URL to user's high-resolution avatar image verified (bool): Whether the user is verified verified_reason (str): Reason for verification gender (str): User's gender """ id: int = Field() screen_name: str = Field() profile_image_url: str = Field() profile_url: str = Field() description: str = Field() follow_count: int = Field() followers_count: str = Field() avatar_hd: str = Field() verified: bool = Field() verified_reason: str = Field() gender: str = Field()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/qinyuanpei/mcp-server-weibo'

If you have feedback or need assistance with the MCP directory API, please join our Discord server