我想抓取一些网页,我正在使用一个名为“SelectorGadget”的Chrome扩展。它是一个CSS选择器。现在以这个URL为例:http://www.www2015.it/documents/proceedings/forms/proceedings.htm CSS选择器为我提供了文件列表的输出:tr~tr+tr td+td a现在,问题是我无法确定如何将此输出传递到beautiful soup。在下面几行中,.select()无法识别这些选择器!在
import requests
page = requests.get("http://www.www2015.it/documents/proceedings/forms/proceedings.htm")
import bs4
soup = bs4.BeautifulSoup(page.content)
soup.select("tr~ tr+ tr td+ td a")
问题是-
BeautifulSoup
有一个very limited CSS selector syntax support。在您的例子中,与~
或+
并行不悖。在如果您希望匹配此页上的
pdf
链接,我将使用以下选择器:相关问题 更多 >
编程相关推荐