How do I deal with Connection refused error in rvest? - r

This is my code:
pkgs <- c("rvest", "urltools")
sapply(pkgs, library, character.only = T)
name <- 'cry'
url1 = URLencode(paste0('https://www.google.co.za/search?q=',name))
htmlpage <- html_session(url1)
Unfortunately, I get the following error:
Error in curl::curl_fetch_memory(url, handle = handle) :
Failed to connect to www.google.co.za port 443: Connection refused
What can I do about the error?

Related

R: cannot read API call - Error in open.connection(con, "rb")

I can see the contents of the API call in webbrowser, but getting this error with jsonlite package: read_json.
Error in open.connection(con, "rb") : connection cannot be opened
AƱso: Warning message:
In open.connection(con, "rb") :
cannot open URL 'https://www.plazavea.com.pe/api/catalog_system/pub/products/search?fq=C:/678/687/&_from=21&_to=41&O=OrderByScoreDESC&': HTTP status was '206 Partial Content'
Code::
library(rvest)
library(tidyverse)
library(jsonlite)
api_request <- "https://www.plazavea.com.pe/api/catalog_system/pub/products/search?fq=C:/678/687/&_from=21&_to=41&O=OrderByScoreDESC&"
product_data <- jsonlite::read_json(api_request)
Use httr and then extract as = 'text' and pass over to parse_json(), or simply specify as = 'parsed' in the content() call on the response object.
library(httr)
api_request <- "https://www.plazavea.com.pe/api/catalog_system/pub/products/search?fq=C:/678/687/&_from=21&_to=41&O=OrderByScoreDESC&"
product_data <- content(httr::GET(api_request), as = 'parsed')

Error in getGEO command in GEOquery

I`m running the following commands to get the data from GEO
library(GEOquery)
gset <- getGEO("GSE9476", GSEMatrix =TRUE, AnnotGPL=TRUE)
But, faced the following error
https://ftp.ncbi.nlm.nih.gov/geo/series/GSE9nnn/GSE9476/matrix/
Error in function (type, msg, asError = TRUE) :
error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

R: unable to download file

I wan to download a file using the following request:
request <- 'http://earthserver.ecmwf.int/rasdaman/ows?service=WCS&version=2.0.1&request=ProcessCoverages&query=for c in (geff_fire_weather_index) return encode(c[Lat(35:47),Long(6:18),ansi("2015-01-01T00:00":"2015-12-31T00:00")],"netcdf")'
download.file(url = request, destfile = "rea.nc")
If I run this using the browser it works no problem but in R it fails with the following error message:
downloaded 0 bytes
Error in download.file(url = request2, destfile = "rea.nc") :
cannot download all files
In addition: Warning message:
In download.file(url = request2, destfile = "rea.nc") :
URL 'http://earthserver.ecmwf.int/rasdaman/ows?service=WCS&version=2.0.1&request=ProcessCoverages&query=for c in (geff_fire_weather_index) return encode(c[Lat(35:47),Long(6:18),ansi("2015-01-01T00:00":"2015-12-31T00:00")],"netcdf")': status was 'Couldn't connect to server'
Is there a way to fix this?

R: change port to connect with SFTP server

I have a connection with an ftp server with the following code:
url <- "ftp://MyServer"
userpwd <- "MyUser:MyPass"
filenames <- getURL(url, userpwd = userpwd, ftp.use.epsv = FALSE, dirlistonly = TRUE, port = 22)
filen <- "MyFile.csv"
rawdata <- getURL(paste(url, filen, sep = ""), userpwd = userpwd, crlf = TRUE)
The file will be moved to an SFTP server, so I need to change the input. This new SFTP server is accessed via port 22 instead of the standard port 21. At the moment the connection fails with the following error
Error in function (type, msg, asError = TRUE) :
Failed to connect to MyServer port 21: Connection refused
It takes the wrong port, but how do I tell R to choose port 22?
You need to specify the SFTP protocol in the URL, so the line
url <- "ftp://MyServer"
should become
url <- "sftp://MyServer"
getUrl will then use the SSH port (22).

R: Ryacas package not working properly on Mac

I can't get the Ryacas package to work on Mac. I keep getting this error:
[1] "Starting Yacas!"
In> Error in socketConnection(host = "127.0.0.1", port = 9734, server = FALSE, : cannot open the connection
In addition: Warning message:
In socketConnection(host = "127.0.0.1", port = 9734, server = FALSE, : 127.0.0.1:9734 cannot be opened
Any help would be greatly appreciated.

Resources