MarkupResemblesLocatorWarning:输入看起来更像是文件名而不是标记。您可能想要打开此文件并将文件句柄传递到 Beautiful Soup 中。 汤 = BeautifulSoup(html_doc,"lxml")
(很抱歉问题的格式不好,因为我还是初学者)
from bs4 import BeautifulSoup
html_doc="File_Path"
soup = BeautifulSoup(html_doc,"lxml")
bgs=soup.find_all('img')
print(bgs)
我找到了答案,并认为将其留在这里给可能面临同样问题的人 先打开文件,然后再将其传递到 bs4
html_doc=open("filepath")
然后将其传递到汤对象内部
soup=BeautifulSoup(html_doc,"lxml")