Skip to content
Advertisement

InvalidSchema: No connection adapters were found. When working with Python Web scraper

I am rather new to Web Scraping I have scrapped one of the zip files seen here. The goal is to append them into a final data frame called final_df. Below is a snip of my code that runs well.

JavaScript

This works well for one year of zip files such as 2017 however I am curious if we could get it all in one swoop. My thinking is to create a F string and change the year in each iteration.

JavaScript

If we just isolate the f string we will see an output such as

“https://www.omie.es/es/file-download?parents%5B0%5D=marginalpdbc&filename=marginalpdbc_2020.zip” “https://www.omie.es/es/file-download?parents%5B0%5D=marginalpdbc&filename=marginalpdbc_2021.zip”

…etc.

Yet when I feed this using the above loop I get an error saying “InvalidSchema: No connection adapters were found for ‘”https://www.omie.es/es/file-download?parents%5B0%5D=marginalpdbc&filename=marginalpdbc_2017.zip”‘”

What would be the best workaround?

Advertisement

Answer

This error means that requests module cannot identify what sort of protocol your requests needs (e.g. http, https, ftp etc.)

This happens in your case because you have a leading " character in your url:

JavaScript

Requests is looking for an adapter for "https protocol which doesn’t exist :)

Just delete the extra quotes.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement