草庐IT

beautifulSoup

全部标签

python - Beautiful Soup findAll 没有找到它们

我正在尝试解析网站并使用find_all()获取一些信息方法,但它并没有找到它们。这是代码:#!/usr/bin/python3frombs4importBeautifulSoupfromurllib.requestimporturlopenpage=urlopen("http://mangafox.me/directory/")#print(page.read())soup=BeautifulSoup(page.read())manga_img=soup.findAll('a',{'class':'manga_img'},limit=None)formangainmanga_img:

python - Beautiful Soup findAll 没有找到它们

我正在尝试解析网站并使用find_all()获取一些信息方法,但它并没有找到它们。这是代码:#!/usr/bin/python3frombs4importBeautifulSoupfromurllib.requestimporturlopenpage=urlopen("http://mangafox.me/directory/")#print(page.read())soup=BeautifulSoup(page.read())manga_img=soup.findAll('a',{'class':'manga_img'},limit=None)formangainmanga_img:

python - 不要自动放html、head和body标签,beautifulsoup

在html5lib中使用beautifulsoup,它会自动放置html、head和body标签:BeautifulSoup('FOO','html5lib')#=>FOO我可以设置任何选项,关闭此行为吗? 最佳答案 In[35]:importbs4asbsIn[36]:bs.BeautifulSoup('FOO',"html.parser")Out[36]:FOO这个parsestheHTMLwithPython'sbuiltinHTMLparser.引用文档:Unlikehtml5lib,thisparsermakesnoatt

python - 不要自动放html、head和body标签,beautifulsoup

在html5lib中使用beautifulsoup,它会自动放置html、head和body标签:BeautifulSoup('FOO','html5lib')#=>FOO我可以设置任何选项,关闭此行为吗? 最佳答案 In[35]:importbs4asbsIn[36]:bs.BeautifulSoup('FOO',"html.parser")Out[36]:FOO这个parsestheHTMLwithPython'sbuiltinHTMLparser.引用文档:Unlikehtml5lib,thisparsermakesnoatt

python - 抓取 : SSL: CERTIFICATE_VERIFY_FAILED error for http://en. wikipedia.org

我正在练习“WebScrapingwithPython”中的代码,但我一直遇到这个证书问题:fromurllib.requestimporturlopenfrombs4importBeautifulSoupimportrepages=set()defgetLinks(pageUrl):globalpageshtml=urlopen("http://en.wikipedia.org"+pageUrl)bsObj=BeautifulSoup(html)forlinkinbsObj.findAll("a",href=re.compile("^(/wiki/)")):if'href'inlin

python - 抓取 : SSL: CERTIFICATE_VERIFY_FAILED error for http://en. wikipedia.org

我正在练习“WebScrapingwithPython”中的代码,但我一直遇到这个证书问题:fromurllib.requestimporturlopenfrombs4importBeautifulSoupimportrepages=set()defgetLinks(pageUrl):globalpageshtml=urlopen("http://en.wikipedia.org"+pageUrl)bsObj=BeautifulSoup(html)forlinkinbsObj.findAll("a",href=re.compile("^(/wiki/)")):if'href'inlin

python - BeautifulSoup 和 lxml.html - 更喜欢什么?

这个问题在这里已经有了答案:ParsingHTMLinpython-lxmlorBeautifulSoup?Whichoftheseisbetterforwhatkindsofpurposes?(7个回答)关闭8年前.我正在做一个涉及解析HTML的项目。四处搜索后,我发现了两个可能的选项:BeautifulSoup和lxml.html有什么理由更喜欢其中一个吗?前段时间我曾将lxml用于XML,我觉得我会更适应它,但是BeautifulSoup似乎很常见。我知道我应该使用适合我的那个,但我正在寻找两者的个人经验。 最佳答案 imo,

python - BeautifulSoup 和 lxml.html - 更喜欢什么?

这个问题在这里已经有了答案:ParsingHTMLinpython-lxmlorBeautifulSoup?Whichoftheseisbetterforwhatkindsofpurposes?(7个回答)关闭8年前.我正在做一个涉及解析HTML的项目。四处搜索后,我发现了两个可能的选项:BeautifulSoup和lxml.html有什么理由更喜欢其中一个吗?前段时间我曾将lxml用于XML,我觉得我会更适应它,但是BeautifulSoup似乎很常见。我知道我应该使用适合我的那个,但我正在寻找两者的个人经验。 最佳答案 imo,

python - BeautifulSoup 中是否有 InnerText 等价物?

使用下面的代码:soup=BeautifulSoup(page.read(),fromEncoding="utf-8")result=soup.find('div',{'class':'flagPageTitle'})我得到以下html:Sometexthere我怎样才能得到Sometexthere没有任何标签?BeautifulSoup中是否有InnerText等价物? 最佳答案 你只需要:result=soup.find('div',{'class':'flagPageTitle'}).text

python - BeautifulSoup 中是否有 InnerText 等价物?

使用下面的代码:soup=BeautifulSoup(page.read(),fromEncoding="utf-8")result=soup.find('div',{'class':'flagPageTitle'})我得到以下html:Sometexthere我怎样才能得到Sometexthere没有任何标签?BeautifulSoup中是否有InnerText等价物? 最佳答案 你只需要:result=soup.find('div',{'class':'flagPageTitle'}).text