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
Profileto initialize anInstaClientandTweetClient, which are used to scrape and tweet posts whenstart()is called
…
- class InstaTweet.instatweet.InstaTweet(profile)[source]View on GitHub
Bases:
objectUses 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🠖 scrapepostsfrom its Instagram pages 🠖download_post()&send_tweet()for any new content 🠖 update thepage_map🠖save()the profile if itexistsExample 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
InstaTweetusing a fully configuredProfileThe
Profilewill be used to initialize anInstaClientandTweetClientNote
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
InstaClientusing the loadedProfilesettings- Return type
- get_tweet_client()[source]View on GitHub
Initializes an
TweetClientusing the loadedProfilesettings- Return type
- start(max_posts=12)[source]View on GitHub
InstaTweets all pages that have been added to the loaded
ProfileThe most recent posts from each page will be scraped, then compared to the
scrapedlist in thePAGE_MAPPINGto determine which are new.Up to
max_postsnew posts from each page will then be downloaded and tweetedNote
If
InstaTweetfails todownload_post()orsend_tweet(), thePAGE_MAPPINGwon’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
scrapedlist is empty, no posts will be returned.Instead, the page is “initialized” as follows:
The
scrapedlist 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