-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter_scrape.Rmd
41 lines (34 loc) · 911 Bytes
/
twitter_scrape.Rmd
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
28
29
30
31
32
33
34
35
36
37
38
39
40
---
title: "Text as Data"
description: |
Data Collection
author:
- name: Sathvik
date: 02-20-2022
output:
distill::distill_article:
self_contained: False
---
<style>
body {
text-align: justify}
</style>
personal twitter dev account
``` {r}
library(rtweet)
mytoken <- create_token(
app = "scrapetext",
consumer_key = "C970M0FZrJEKBqZR3HFMsSGvd",
consumer_secret = "r6kLAmeA3TU5h5HxLZT1iVIlUMGvlp2K849YXyXvAlR0L6EOr6 ",
access_token = "3506023692-7hPZkDFjgjXzDmozlsK5kZUsZqQ7XksBuWY0dJN",
access_secret = "GnUrVqxnWld60dJr5qxUji6cDGeZzhhYd06W5VEA16lhn")
```
Collecting n=1000 tweets with #Covid. Saving in rda format
``` {r}
data <- search_tweets("#Covid", include_retweets = TRUE, n = 1000,
retryonratelimit = TRUE, token = mytoken, lang = 'en')
```
Range
```{r}
write_as_csv(data, "twitter_data.csv", prepend_ids = TRUE, na = "", fileEncoding = "UTF-8")
```