From e6431006fbb0489f06ba63cc1ff8d1f673439238 Mon Sep 17 00:00:00 2001 From: mxmehl Date: Sun, 30 Nov 2014 18:58:47 +0100 Subject: [PATCH] bla --- extract-twitter-accounts.R | 5 ++++- functions.R | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/extract-twitter-accounts.R b/extract-twitter-accounts.R index ee50b56..9d7bb36 100644 --- a/extract-twitter-accounts.R +++ b/extract-twitter-accounts.R @@ -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/show.json"; user <- "peteraltmaier" max_count <- "200" max_id <- "999999999999999999" @@ -58,9 +59,11 @@ repeat { screen_name=user, count=max_count, max_id=max_id); +# query <- c(trim_user="true", include_entities="false", +# id="431858659656990721"); if(exists("tweets_full")) { current <- twitter_api_call(api_url, query, api_params) - tweets_temp <- fromJSON(correctJSON(current)) + tweets_temp <- fromJSON(current) tweets_temp <- tweets_temp[keep] tweets_full <- insertRow(tweets_full, tweets_temp) } diff --git a/functions.R b/functions.R index d74819d..ea982d4 100644 --- a/functions.R +++ b/functions.R @@ -5,8 +5,16 @@ correctJSON <- function(string) { string <- str_replace_all(string, pattern = perl('\\\\(?![tn"])'), replacement = " ") string <- str_replace_all(string, pattern = "\n", replacement = " ") string <- str_replace_all(string, pattern = "\r", replacement = " ") - string <- str_replace_all(string, pattern = "^", replacement = " ") - \xed\xa0\xbd\xed\xb1\x8d\xed\xa0\xbd\xed\xb8\x8e\ + string <- str_replace_all(string, pattern = "\\^", replacement = " ") + 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) }