MislavSag / findata

0 stars 2 forks source link

InvestingCom.R #1

Open rnfermincota opened 2 years ago

rnfermincota commented 2 years ago

Good afternoon. I am writing regarding the file: https://github.com/MislavSag/findata/blob/main/R/InvestingCom.R I was wondering if it is feasible to get your guidance on how to fix get_investingcom_earnings_calendar. When I try to run the function I get the following error.

Error: lexical error: invalid char in json text. <!DOCTYPE HTML> <html lang="en- (right here) ------^

I have been trying to make the proper changes to add_headers to see if I can fix it but with no luck: www.investing.com/earnings-calendar/Service/getCalendarFilteredData

I am currently reading the following posts to see I can get it working: https://stackoverflow.com/questions/41665554/why-i-cant-get-a-right-response-from-server-using-curl https://snyk.io/advisor/python/investpy/functions/investpy.utils.user_agent.get_random

I do thank you in advance for your support and consideration. Nico

MislavSag commented 2 years ago

Can you show your code (reprex)?

rnfermincota commented 2 years ago

As requested and thank you very much https://gist.github.com/rnfermincota/b7d08dc089f562964c8426c00b095e45

MislavSag commented 2 years ago

The code youhave tried.

For example:

library(findata)
ic = InvestingCom$new()
ic$get_investingcom_earnings_calendar(Sys.Date - 10, Sys.Date)
rnfermincota commented 2 years ago

Still getting the same error:

library(findata) ic = InvestingCom$new() [1] "Good" ic$get_investingcom_earnings_calendar(Sys.Date - 10, Sys.Date) Error in Sys.Date - 10 : non-numeric argument to binary operator ic$get_investingcom_earnings_calendar(Sys.Date() - 10, Sys.Date()) Error in add_headers(Content-Type = "application/x-www-form-urlencoded", : could not find function "add_headers" library(httr) ic$get_investingcom_earnings_calendar(Sys.Date() - 10, Sys.Date()) Error: lexical error: invalid char in json text. <!DOCTYPE HTML> <html lang="en- (right here) ------^

MislavSag commented 2 years ago

Please try now again. I have pushed new version with lots of changes.

rnfermincota commented 2 years ago

Unfortunately after installing the new version of the pkg and FireFox on my Macbook Pro I am still getting the same error:

library(findata) ic = InvestingCom$new() [1] "Good" ic$get_investingcom_earnings_calendar(Sys.Date() - 10, Sys.Date()) Error: lexical error: invalid char in json text. <!DOCTYPE HTML> <html lang="en- (right here) ------^

Does it works on your computer?