vladkens / twscrape

2024! X / Twitter API scrapper with authorization support. Allows you to scrape search results, User's profiles (followers/following), Tweets (favoriters/retweeters) and more.
https://pypi.org/project/twscrape/
MIT License
1.13k stars 132 forks source link

Question: Check if tweet is pinned #201

Open FroostySnoowman opened 5 months ago

FroostySnoowman commented 5 months ago

How would I check to see if a tweet is pinned?

vladkens commented 5 months ago

Hi, @FroostySnoowman.

What api method you use? Actually is no flags about it any model now.

If you scrape user profiles, ids should be in chronological order expect 1-3 first which can be pinned. So you can write some code to detect this

vladkens commented 5 months ago

Added in v0.13

import asyncio

from twscrape import API

async def main():
    api = API()

    async for doc in api.user_tweets(2244994945, limit=10):
        print(doc.url, doc.id in doc.user.pinnedIds)

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