Skip to content
Tayyab Kharl edited this page Jun 24, 2024 · 6 revisions

FAQs

Not working on VPS/Server

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

How to access the text/content or date of Tweet

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

Listen for New Tweets

  1. Best method to check for new tweets is using List
  2. 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 New Limits

Twitter after Elon takeover has added many restrictions to whole platform. Some of them are:

  1. Tweets of a User can be fetched of last 7-10 days only , for going beyond that use Search method
  2. 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
  3. Getting a tweet detail without logging in will not fetch any comments on that Tweet
  4. Every method has rate limit as low as 50 requests per 15 minutes

Access the original Request JSON Response

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.

Proxy Support

Twitter class accepts optional argument proxy which can be a dict 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 = Twitter("session", proxy=proxy)

# If the SSL certificate verification is failing 

client = Twitter("session", proxy=proxy, verify=False)

Creating Tweet Thread

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 `Twitter` class

threads = ["Thread 1", "2 Thread", "Three Thread"]
reply_to = None
for thread in threads:
    tweet = client.create_tweet(thread, batch_compose=True, reply_to=reply_to)
    reply_to = tweet.id

Memory Session

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 Twitter

client = Twitter(MemorySession()) # Session will be stored in Memory instead of Disk
client.load_auth_token(...)

print(client.me)

Advance Search

Twitter has advance search feature using which you can filter out the search results

Filtering Date

# assuming `client` is authenticated instance of `Twitter`
search_results = client.search("github until:2023-05-01 since:2022-05-01")

Interactions Filtering

search_results = client.search("github min_replies:280 min_faves:280 min_retweets:280")

Filtering Users

search_results = client.search("github (from:kharltayyab OR from:elonmusk) (to:reply_to OR to:reply_to2) (@mention OR @mention3 OR @23)")

More about advance search

Captcha Support

Right now tweety supports three captcha solver services

  • Anticaptcha
  • Capsolver
  • 2Capthca
from tweety.captcha import TwoCaptcha
from tweety import Twitter
from tweety.session import MemorySession

proxy - ...

captcha = TwoCaptcha(api_key)

client = Twitter(MemorySession(), proxy=proxy, captcha_solver=captcha)