froost1999 froost1999 - 27 days ago 16
Python Question

InvalidSchema("No connection adapters were found for '%s'" % url) in python

This is my first time on webscraping , so dont get hard on me. I am learning to scrape the data out of site but I am getting the following error:


raise InvalidSchema("No connection adapters were found for '%s'" %
url) InvalidSchema: No connection adapters were found for
'('http://en.oxforddictionaries.com/definition/good', 'html.parser')'


This is my code:

import requests
from bs4 import BeautifulSoup


url=('http://en.oxforddictionaries.com/definition/good',"html.parser")
r=requests.get(url)
soup=BeautifulSoup(r.content)
links=soup.find_all("a")


I have seen other answers and notice i need to put
http://
, I have done that but to no avail.

Thank you for your time.

Answer

The 'html.parser' parameter should be passed to BeautifulSoup not requests.get. Passing it to the latter makes the url nonsensical to requests.get:

url = 'http://en.oxforddictionaries.com/definition/good'
...
soup = BeautifulSoup(r.content, 'html.parser')
Comments