requests.exceptions.JSONDecodeError:

Hello,

I’ve just got this Error while loading my app to streamlit cloud. The same code worked perfectly so far, that’s why I have no idea what to do now?

Hi @Mike7205

Could you provide more context or details about the error message? This will help us provide a more accurate response! :slight_smile:

Thanks,
Charly

When you say the same code worked perfectly so far, is that in a version running locally or a deployed streamlit cloud version?

If it’s the former, it may be the case that in the cloud version, wherever you’re trying to connect to blocks traffic to prevent web scraping. Try get the status_code from the response before you attempt to return a json object, that should help inform what’s going on.

See Error - requests.exceptions.JSONDecodeError - #2 by randyzwitch

Hey @Mike7205 ,

Just a tip of advice here. Web scraping works a bit funny and isn’t always reliable when hosting it on the streamlit cloud. I’d suggest you create a fastapi wrapper for your scraper and query to it instead of the scraper itself. This way, you should have more reliable code that doesn’t break. You’ll also be able to handle the errors gracefully.

Hope this helps!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.