-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrawling.py
More file actions
27 lines (20 loc) · 821 Bytes
/
Crawling.py
File metadata and controls
27 lines (20 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import re
import tweepy
consumer_key = "your_consumer_key"
consumer_secret = "your_consumer_secret"
access_key = "your_access_key"
access_secret = "your_access_secret"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
search_key = '@pln_123'
api = tweepy.API(auth)
tweets = tweepy.Cursor(api.search,
q=search_key,
tweet_mode="extended").items(1000)
with open("tweets_all_25.txt", "w+", encoding="utf-8") as file_tweets_txt:
for tweet in tweets:
if not re.search(r'\bRT @\S*\b', tweet.full_text):
date = tweet.created_at
text = tweet.full_text.replace('\n', ' ')
file_tweets_txt.write("%s | %s\n" % (date, text))
file_tweets_txt.close()