Home>
I am trying to use the twitter API for practice as well, but
https://qiita.com/bakira/items/00743d10ec42993f85eb#comments
When I copy and paste the code on this site and try it for a while, nothing is displayed and it ends.
This code is to get and display the timeline of TWITTER
python
import json
from requests_oauthlib import OAuth1Session
import key
CK = key.consumer_key
CS = key.consumer_secret
AT = key.token
ATS = key.token_secret
twitter = OAuth1Session(CK, CS, AT, ATS)
url = "https://api.twitter.com/1.1/statuses/user_timeline.json"
params ={'count':5}
res = twitter.get(url, params = params)
if res.status_code == 200:
timelines = json.loads(res.text)
for line in timelines:
print(line['user']['name']+'::'+line['text'])
print(line['created_at'])
print('*******************************************')
else: #When communication is not successful
print("Failed: %d" %res.status_code)
What I tried
I don't know anything because I am just beginning to use python and IDE as a student.
-
Answer # 1
Related articles
- python - how to arrange and display pandas data frame like data frame in html
- i want to display screens with different window sizes when i press the [python/tkinter] tab
- python - i want to display the scraping result in the browser
- excel python i want to get the display result instead of the conditional statement
- display images by drag and drop on wxpython gui
- python - i want to display an image with pysimplegui, but an error occurs
- i want to get the timeline of multiple users with twitter api
- i want to get the value from a constant in python and display it
- how to scrape in python and display in a browser?
- python matplotlibpyplot i get an error trying to display a moving average on a candlestick chart
- python image display error beginner, thank you
- python - get the follower's screen name with the twitter api
- python - i want to display the sensing data as a graph using the value sent by post from a web browser
- emoji counting using twitter api in python
- error display on python discord bot
- python - i want to display the next window when i press the button!
- i want to display images periodically in python, what should i do?
- python - confusion matrix display in image recognition on cnn
- error display on python discord bot
- python - [opencv] i want to display the area of each object at the position adjacent to the object
Related questions
- python : List of dictionaries?
- javascript : How can I get the hidden site API
- How to write script via API in Python?
- How to translate into a normal format -a date from numbers. Python
- Hello, how can I bypass recaptcha v2 on a website via python, then login to the website and create cookies?
- You need to add a hyperlink and data from api for telegram bot in python
The result is
res.status_code == 200
When is true andfor line in timelines:
I wonder if it's just that I haven't tweeted once, because inside is never executed.