This commit is contained in:
2014-11-30 18:58:47 +01:00
parent 0be709ff08
commit e6431006fb
2 changed files with 14 additions and 3 deletions
+4 -1
View File
@@ -47,6 +47,7 @@ api_params <- c(
) )
api_url <- "https://api.twitter.com/1.1/statuses/user_timeline.json"; api_url <- "https://api.twitter.com/1.1/statuses/user_timeline.json";
# api_url <- "https://api.twitter.com/1.1/statuses/show.json";
user <- "peteraltmaier" user <- "peteraltmaier"
max_count <- "200" max_count <- "200"
max_id <- "999999999999999999" max_id <- "999999999999999999"
@@ -58,9 +59,11 @@ repeat {
screen_name=user, screen_name=user,
count=max_count, count=max_count,
max_id=max_id); max_id=max_id);
# query <- c(trim_user="true", include_entities="false",
# id="431858659656990721");
if(exists("tweets_full")) { if(exists("tweets_full")) {
current <- twitter_api_call(api_url, query, api_params) current <- twitter_api_call(api_url, query, api_params)
tweets_temp <- fromJSON(correctJSON(current)) tweets_temp <- fromJSON(current)
tweets_temp <- tweets_temp[keep] tweets_temp <- tweets_temp[keep]
tweets_full <- insertRow(tweets_full, tweets_temp) tweets_full <- insertRow(tweets_full, tweets_temp)
} }
+10 -2
View File
@@ -5,8 +5,16 @@ correctJSON <- function(string) {
string <- str_replace_all(string, pattern = perl('\\\\(?![tn"])'), replacement = " ") string <- str_replace_all(string, pattern = perl('\\\\(?![tn"])'), replacement = " ")
string <- str_replace_all(string, pattern = "\n", replacement = " ") string <- str_replace_all(string, pattern = "\n", replacement = " ")
string <- str_replace_all(string, pattern = "\r", replacement = " ") string <- str_replace_all(string, pattern = "\r", replacement = " ")
string <- str_replace_all(string, pattern = "^", replacement = " ") string <- str_replace_all(string, pattern = "\\^", replacement = " ")
\xed\xa0\xbd\xed\xb1\x8d\xed\xa0\xbd\xed\xb8\x8e\ return(string)
}
correctJSON2 <- function(string) {
#string <- sub(x=string, pattern = perl('\\\\(?![tn"])'), replacement = " ")
string <- gsub(x=string, pattern = "\n", replacement = " ")
string <- gsub(x=string, pattern = "\r", replacement = " ")
string <- gsub(x=string, pattern = "\\^", replacement = " ")
#\xed\xa0\xbd\xed\xb1\x8d\xed\xa0\xbd\xed\xb8\x8e\
return(string) return(string)
} }