I want to crawl the contents of Twitter with Python I don't think the Tweepy package is running, what should I do? TT
(May I know the maximum collection limit for Twitter?)
The code is as follows
import tweepy
consumer_key = "DUtpRNHpSEFhVj1dJ890cLIya"
consumer_secret = "08CA1vAGuZWHsbQUovqxqOBuicw44fLxalNE8TLDHTiDNoyIfb"
access_token = "908202087032352768-WuZtPZDBubODjEuND1QawgpDPcVioEc"
access_token_secret = "OrTedtrPE0zlu4JdcmLuGpjZjw3okYqFMwGwrci9uJzoF"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
location = "%s,%s,%s" % ("35.95", "128.25", "1000 km") # search criteria (central Korea) coordinates, radius
Keyword = "Small but certain happiness"
wfile = open(os.getcwd()+"/twitter.txt", mode='w')
cursor = tweepy.Cursor(api.search,
q=keyword,
Tweets written after 'since='2016-01-01', #2015-01-01 are imported
count=100, #Twitter to return per page up to 100
geocode=location,
include_entities=True)
for i, tweet in enumerate(cursor.items()):
print("{}: {}".format(i, tweet.text))
wfile.write(tweet.text + '\n')
wfile.close()
I came across it while working on a team project (Of course, you've already solved it by now...)LOL) I'm just going to post a solution in case other people experience this problem.
You can see that the file is named tweepy.py
Due to the Python nature, this will attempt to import itself instead of the tweepy library.
Change the file name so that it does not overlap with other libraries, and try running it again again. :)
Additionally, all information on collection restrictions and more can be found at the following URL: https://developer.twitter.com
548 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
547 Who developed the "avformat-59.dll" that comes with FFmpeg?
549 PHP ssh2_scp_send fails to send files as intended
546 Understanding How to Configure Google API Key
537 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.