alvarobartt / investpy

Financial Data Extraction from Investing.com with Python
https://investpy.readthedocs.io/
MIT License
1.59k stars 374 forks source link

Expecting value: line 1 column 1 (char 0) #615

Open normanvdmeijden opened 1 year ago

normanvdmeijden commented 1 year ago

Hi guys,

Yesterday I could retrieve the calender info with any issues, trying it this morning (same code), I received the following error below. How can I fix this?

Traceback (most recent call last): File "C:\Users\vanderMeijden\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\requests\models.py", line 971, in json return complexjson.loads(self.text, **kwargs) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64qbz5n2kfra8p0\lib\json\init.py", line 346, in loads
return _default_decoder.decode(s) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64
qbz5n2kfra8p0\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "c:\Users\vanderMeijden\Desktop\EIA\EIACalender", line 28, in calender = investpy.news.economic_calendar(from_date="19/10/2022", to_date="21/10/2022") File "C:\Users\vanderMeijden\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\investpy\news.py", line 251, in economic_calendar root = fromstring(req.json()["data"]) File "C:\Users\vanderMeijden\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\requests\models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Thanks, Norman

Lontaren commented 1 year ago

I have the same problem

brianchu1986 commented 1 year ago

same problem here, response 403 forbiden.

varshasahasrabuddhe commented 1 year ago

same problem.

IlliaBoloto commented 1 year ago

Same!

alvarobartt commented 1 year ago

Hi everyone, so this issue is due to Investing.com's new protection with Cloudflare V2, this has affected investpy and investiny, but I've already contacted them so as to see whether we can get to a collaboration agreement, I'll keep you all posted, sorry for the inconveniences...

normanvdmeijden commented 1 year ago

@alvarobartt thanks for the update. Really appreciate all the work you have done and what you have made possible thusfar!

jazz-g commented 1 year ago

I've gotten the economic_calendar module working again by using the library cfscraper, and using that to make requests by adding import cfscraper to the imports and scraper = cfscrape.create_scraper() above the while True loop, and then replacing req = requests.post(url, headers=headers, data=data) with req = scraper.post(url, headers=headers, data=data)

brianchu1986 commented 1 year ago

I've gotten the economic_calendar module working again by using the library cfscraper, and using that to make requests by adding import cfscraper to the imports and scraper = cfscrape.create_scraper() above the while True loop, and then replacing req = requests.post(url, headers=headers, data=data) with req = scraper.post(url, headers=headers, data=data)

@jazz-g it works with cfscrape. thanks for info.

normanvdmeijden commented 1 year ago

@jazz-g Thanks, but when I tried this I am requested for a license key. any idea what I am doing wrong?

Lontaren commented 1 year ago

Hi! What a great community we have, thanks for the solution. @normanvdmeijden I believe you're importing the wrong module, it's supposed to be crscrape (not crscraper) Thanks for the solution @jazz-g

normanvdmeijden commented 1 year ago

@jazz-g @Lontaren Yes it is up and running now, thanks for all the support

varshasahasrabuddhe commented 1 year ago

i need a little bit of help here. i am using below function. how do i get it using cfscrape exogs = investpy.economic_calendar(time_zone = "GMT", countries = ["United States"], importances = ['high','medium','low'],from_date= date_from, to_date = date_to)

Lontaren commented 1 year ago

@varshasahasrabuddhe You need to modify the investpy package (in this case the news.py file) with the code @jazz-g suggested

varshasahasrabuddhe commented 1 year ago

Thank you Lontaren and @jazz-g

srinivasakumar-a commented 4 months ago

@varshasahasrabuddhe You need to modify the investpy package (in this case the news.py file) with the code @jazz-g suggested

Thanks a ton! 🥇 this solved my issue :)