Created
June 30, 2022 09:04
-
-
Save rnfermincota/b7d08dc089f562964c8426c00b095e45 to your computer and use it in GitHub Desktop.
InvestingCom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httr) | |
date_to <- Sys.Date(); date_from <- date_to-10 | |
# solve No visible binding for global variable | |
. <- NULL | |
# make POST request to invest.com earings calendar | |
# print("POST request to investing.com") | |
p <- POST( | |
url = "https://www.investing.com/earnings-calendar/Service/getCalendarFilteredData", | |
body = list( | |
"country[]" = "5", | |
"dateFrom" = date_from, | |
"dateTo" = date_to, | |
"currentTab" = "custom", | |
"limit_from" = "0" | |
), | |
add_headers( | |
"Content-Type" = "application/x-www-form-urlencoded", | |
"Referer" = "https://www.investing.com/earnings-calendar/", | |
"User-Agent" = "Mozilla/5.0", | |
"X-Requested-With" = "XMLHttpRequest" | |
), | |
encode = "form" | |
) | |
# parse content | |
# print("PArse content.") | |
json <- content(p, type = "application/json") | |
# Error: lexical error: invalid char in json text. | |
# <!DOCTYPE HTML> <html lang="en- | |
# (right here) ------^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment