32
loading...
This website collects cookies to deliver better user experience
mkdir twitter-test
cd twitter-test
python3 -m pip install twython
python3 -m pip install requests
from twython import Twython
import requests
APP_KEY = "YOUR API KEY FROM TWITTER"
APP_SECRET = "YOUR API SECRET FROM TWITTER"
twitter = Twython(APP_KEY, APP_SECRET)
auth = twitter.get_authentication_tokens()
OAUTH_TOKEN = auth['oauth_token']
OAUTH_TOKEN_SECRET = auth['oauth_token_secret']
oauth_verifier_url = auth['auth_url']
oauth_verifier = requests.get(oauth_verifier_url)
print("Verifier URL is:" + oauth_verifier_url)
print("OAUTH_TOKEN is:" + OAUTH_TOKEN)
print("OAUTH TOKEN SECRET is:" + OAUTH_TOKEN_SECRET)
python3 authenticate.py
Verifier URL is: https://api.twitter.com/oauth/authenticate?oauth_token=XXXXX
OAUTH_TOKEN is: XXXXX
OAUTH TOKEN SECRET is: XXXXX
from twython import Twython
import requests
APP_KEY = "YOUR APP KEY FROM TWITTER"
APP_SECRET = "YOUR APP SECRET FROM TWITTER"
twitter = Twython(APP_KEY, APP_SECRET)
twitter = Twython(APP_KEY, APP_SECRET,
OAUTH TOKEN FROM ABOVE SCRIPT, OAUTH TOKEN SECRET FROM ABOVE SCRIPT)
final_step = twitter.get_authorized_tokens(YOUR AUTH CODE HERE)
OAUTH_TOKEN = final_step['oauth_token']
OAUTH_TOKEN_SECRET = final_step['oauth_token_secret']
print(‘Token: ’+OAUTH_TOKEN)
print(‘Secret:’ + OAUTH_TOKEN_SECRET)
OAUTH_TOKEN
and OAUTH_TOKEN_SECRET
but this time these credentials are actually attached to your own profile so that the combination of APP_KEY, APP_SECRET can identify your profile’s credentials.Token: XXXXX
Secret: XXXXX
from twython import Twython
import requests
APP_KEY = "YOUR APP API KEY"
APP_SECRET = "YOUR APP SECRET"
OAUTH_TOKEN = "TOKEN FROM ABOVE SCRIPT"
OAUTH_TOKEN_SECRET = "SECRET FROM ABOVE SCRIPT"
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
twitter.update_status(status='@geekyhumans I made it!!')
update_status
that is used for tweeting on Twitter.beautifulsoup
to fetch newly published posts from the sitemap of this website and some others also and then fetched the