web scraping - How to pull data from News River API into R -
trying pull data newsriver api r. convert json provided dataframe further analysis. able input own search terms , domain search variables.
library(httr) library(jsonlite) set_config(config(ssl_verifypeer = 0l)) search_1 <- "amazon" search_2 <- "world domination" website <- "bloomberg.com" url <- sprintf('https://api.newsriver.io/v2/search?query=text%%3a%s%%20or%%20text%%3a%s%%20or%%20website.domainname%%3a%s%%20or%%20language%%3aen&sortby=_score&sortorder=desc&limit=100', search_1, search_2, website) api_key <- "mykey" news <- get(url, add_headers(authorization = paste(api_key, sep = ""))) news_txt <- content(news, = "text") news_china_df <- fromjson(news_txt)
Comments
Post a Comment