A python twitter bot that posts history facts related to the day from Wikipedia with related images. This is meant to function using python3.
-
BeautifulSoup - Scrapes webpages and parces the HTML to get the daily event data and images.
-
tweepy - Tweets to a twitter account using python code.
-
lxml - Parcer used for BeautifulSoup.
-
requests - Grabs page HTML and downloads images.
import tweepy
def authFunc():
auth = tweepy.OAuthHandler("CONSUMER_KEY","CONSUMER_SECRET")
auth.set_access_token("ACCESS_TOKEN", "ACCESS_TOKEN_SECRET")
return tweepy.API(auth)
The file or function should look like this. I have not included then in the repo for the security of my twitter account.
You can get the keys and tokens by signing up for a twitter developer account. For detailed tutorial, look at this guide.