The InstaTweet
class
Not to be confused with the package, the InstaTweet
class is the main point of interaction for a user of
the package
It uses a fully configured
Profile
to initialize anInstaClient
andTweetClient
, which are used to scrape and tweet posts whenstart()
is called
…
- class InstaTweet.instatweet.InstaTweet(profile)[source]View on GitHub
Bases:
object
Uses the settings from a Profile to do the actual InstaTweeting
You might be wondering, what’s InstaTweeting? According to TDK Dictionary:
InstaTweet (verb):
To load a
Profile
🠖 scrapeposts
from its Instagram pages 🠖download_post()
&send_tweet()
for any new content 🠖 update thepage_map
🠖save()
the profile if itexists
Example Sentence
Oh, you lost 700 Twitter followers after you shared your IG post? Well maybe if people actually saw the picture and not just the caption your tweet would’ve been less creepy. You should’ve InstaTweeted it.
- __init__(profile)[source]View on GitHub
Initializes
InstaTweet
using a fully configuredProfile
The
Profile
will be used to initialize anInstaClient
andTweetClient
Note
InstaTweet won’t
validate()
the Profile settings until you callstart()
- classmethod load(profile_name, local=True)[source]View on GitHub
Loads a profile by name
- Parameters
- Return type
- get_proxies()[source]View on GitHub
Retrieve proxies using the loaded Profile’s
proxy_key
- get_insta_client()[source]View on GitHub
Initializes an
InstaClient
using the loadedProfile
settings- Return type
- get_tweet_client()[source]View on GitHub
Initializes an
TweetClient
using the loadedProfile
settings- Return type
- start(max_posts=12)[source]View on GitHub
InstaTweets all pages that have been added to the loaded
Profile
The most recent posts from each page will be scraped, then compared to the
scraped
list in thePAGE_MAPPING
to determine which are new.Up to
max_posts
new posts from each page will then be downloaded and tweetedNote
If
InstaTweet
fails todownload_post()
orsend_tweet()
, thePAGE_MAPPING
won’t be updatedThis ensures that failed repost attempts are retried in the next call to
start()
If a save file for the Profile already
exists
, successful reposts will trigger a call tosave()
- Parameters
max_posts (int) – the maximum number of new posts to download and tweet per page
- get_new_posts(insta_page)[source]View on GitHub
Scrapes recent posts from an Instagram page and returns all posts that haven’t been tweeted yet
NOTE: If a page’s
scraped
list is empty, no posts will be returned.Instead, the page is “initialized” as follows:
The
scraped
list will be populated with the ID’s from the most recent postsThese IDs are then used in future method calls to determine which posts to tweet