I am trying to open and html file with bs4 and i get this error

73 views Asked by At

MarkupResemblesLocatorWarning: The input looks more like a filename than markup. You may want to open this file and pass the filehandle into Beautiful Soup. soup = BeautifulSoup(html_doc,"lxml")

(sorry for the poor formatting of the question as im still a beginner )

from bs4 import BeautifulSoup
html_doc="File_Path"
soup = BeautifulSoup(html_doc,"lxml")
bgs=soup.find_all('img')
print(bgs)
1

There are 1 answers

0
Jentcold On

I figured out the answer and thought it leave it here for anyone who might face the same problem open the file first before passing it in bs4

html_doc=open("filepath")

then pass it inside the soup object

soup=BeautifulSoup(html_doc,"lxml")