-
Notifications
You must be signed in to change notification settings - Fork 75
FAQs
Twitter blocks the request from several well known VPS/Server providers Like AWS or Google Cloud, make sure to use good proxy in that case
Tweety returns a object in response of every of method , you can get the information by accessing the attributes of objects.
For Instance : tweet_detail
method will return the Tweet
object, to get tweet text you can use .text
attribute.
More about objects here
Best method to check for new tweets is using List
You can also fetch tweets from New Tweet Notification using get_tweet_notifications
Note
Replies are only become part of list when both users involved in that reply are member of that list. If user2 is replying to user1 , the reply will only appear in list if user2 is also member of that list
Twitter after Elon takeover has added many restrictions to whole platform. Some of them are:
- Tweets of a User can be fetched of last 7-10 days only , for going beyond that use Search method
- Tweets of a User when accessing without logging in are by default sorted according to number of likes and we can get only one page
- Getting a tweet detail without logging in will not fetch any comments on that Tweet
- Every method has rate limit as low as 50 requests per 15 minutes
By Default Tweety returns parsed object , but if you want to access the Original Response received from Twitter use the .get_raw()
method.
Note
get_raw()
method is only available with DataTypes who has parent Class of _TwType
.
Twitter
class accepts optional argument proxy
which can be a str
or tweety.types.Proxy
from tweety import Twitter
from tweety.types import Proxy, PROXY_TYPE_HTTP
proxy = Proxy(host="127.0.0.1", port=8080, proxy_type=PROXY_TYPE_HTTP, username="username", password="password")
client = TwitterAsync("session", proxy=proxy)
# If the SSL certificate verification is failing
client = TwitterAsync("session", proxy=proxy, verify=False)
In order to create a thread you need to reply to previous tweet with batch_compose
argument set to True
# client is authenticated instance of `TwitterAsync` class
threads = ["Thread 1", "2 Thread", "Three Thread"]
reply_to = None
for thread in threads:
tweet = await client.create_tweet(thread, batch_compose=True, reply_to=reply_to)
reply_to = tweet.id
If you don't want to create a session on disk, you can create it in memory only too.
from tweety.session import MemorySession
from tweety import TwitterAsync
client = TwitterAsync(MemorySession()) # Session will be stored in Memory instead of Disk
await client.load_auth_token(...)
print(client.me)
Twitter has advance search feature using which you can filter out the search results
# assuming `client` is authenticated instance of `Twitter`
search_results = await client.search("github until:2023-05-01 since:2022-05-01")
search_results = await client.search("github min_replies:280 min_faves:280 min_retweets:280")
search_results = await client.search("github (from:kharltayyab OR from:elonmusk) (to:reply_to OR to:reply_to2) (@mention OR @mention3 OR @23)")
More about advance search