Scraping RSS XML Feed - r

I am trying to scrape an RSS feed every hour to run sentiment analysis on headlines of stocks I own. However, I am having issues scraping the rss xml feed. I have tried packages: httr, XML, RCurl and tidyRSS.
I have previously used these packages to successfully scrape xml code, so I am struggling to diagnose the issue. From another answer, I tried dropping the s in https, but no success.
Code with corresponding errors:
my_url <- "https://www.nasdaq.com/feed/rssoutbound?symbol=BAC"
## Failure when receiving data from the peer
feed <- httr::GET(url = my_url)
## Error: 1: failed to load external entity
feed <- XML::xmlTreeParse(my_url, isURL = TRUE)
## error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
feed <- RCurl::getURL(url = my_url)
## Attempt to fetch feed resulted in an error: Error in curl::curl_fetch_memory(url, handle = handle): Failure when receiving data from the peer
feed <- tidyRSS::tidyfeed(feed = my_url)
I am using R - 4.1.1 with all mentioned packages updated to latest version.

Related

HTTR GET request error: Failed writing received data to disk/application

I am trying to send the following API GET Request with the HTTR library in R:
GET('https://api.vitaldb.net/afd182c102c5af625d3f217280b3766d453d9e3f')
But I get the following error message
Error in curl::curl_fetch_memory(url, handle = handle) : Failed writing received data to disk/application
I have tested the specific endpoint in Postman where I am able to retrieve the corret data, but somehow the R command doesn't work.
Can anyone help me?
According to the API docs the file is GZip-compressed CSV format so you could do the following (though someone might know of a one-liner download and read)
library(data.table)
download.file(url = "https://api.vitaldb.net/afd182c102c5af625d3f217280b3766d453d9e3f.csv.gz",
destfile = file.path("data.csv.gz"))
d <- fread("data.csv.gz", sep = ',')

HTTP error 403 when using jsonlite fromJSON in RStudio

library(jsonlite)
url <- "https://api.nftport.xyz/v0/nfts"
data <- fromJSON(url)
a <- as.data.frame(data)
I am new to API, JSON, and R in general. Would like to ask how do I go about building a connection with the API, and retrieving the JSON format, and converting it into a dataframe that I can use.
Have been facing this error.
Error in open.connection(con, "rb") : HTTP error 403.

Problems with downloading infromation from Google Trends in R

I tried to download infromation from Google trends to object in R. Therea are several packages for it but I decided to use Gtrends. I met with unexpected problem and there is no information about it.
library(gtrendsR)
> google.trends = gtrends(c("blu-ray"), gprop = "web", time = "all")
Error in curl::curl_fetch_memory(url) :
schannel: failed to receive handshake, SSL/TLS connection failed
I guess there are some problems with connection but I dont know how to solve it. Any ideas? Thanks a lot in advance.
Version of R: 3.5.0.
Version of package: 1.4.1

Unable to download financial data with getFin() in R - HTTP status is '403 Forbidden'

I am trying to download financial data of companies. I have used getFin() quite a lot without encountering any problem.
Right now, I am unable to download any data and when I use e.g. this code (and basically any other valid symbol instead of "AAPL"):
getFin("AAPL")
I get the following error message:
Error in download.file(paste(google.fin, Symbol, sep = ""), quiet = TRUE, :
cannot open URL 'http://finance.google.com/finance?fstype=ii&q=AAPL'
In addition: Warning message:
In download.file(paste(google.fin, Symbol, sep = ""), quiet = TRUE, :
cannot open URL 'http://finance.google.com/finance?fstype=ii&q=AAPL': HTTP status was '403 Forbidden'
However, if I try to access the website http://finance.google.com/finance?fstype=ii&q=AAPL via a browser, I have no problem with accessing the website.
So why am I unable to download data with getFin() in RStudio all of the sudden?
Have you tried clearing your cache or going incognito and accessing the URL?
Assuming you are on a linux server and using PHP you could try updating your PHP version it should be on the Google finance api documentation

Error working with jsonlite R package

I want to read in data from an API to R using jsonlite, but gives me the error message shown below. Before some months, it was working fine. What could be the reason that it is not working now? I am trying to get data from the openFDA API:
library(jsonlite)
fda=fromJSON("https://api.fda.gov/drug/event.json?search=receivedate:[20040101+TO+20160101]&count=receivedate")
Error in open.connection(con, "rb") :
Peer certificate cannot be authenticated with given CA certificates

Resources