2.2 再端一碗BeautifulSoup
作者:
modao233 | 来源:发表于
2019-08-06 22:21 被阅读0次
掌握BeautifulSoup的基本用法
from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen("http://pythonscraping.com/pages/warandpeace.html")
bsObj = BeautifulSoup(html.read(), "html.parser")
# nameList = bsObj.findAll("span", {"class" : "green"}, limit=10)
# for name in nameList:
# print(name.get_text())
# nameList = bsObj.findAll(text = "the prince")
# print(len(nameList))
allText = bsObj.findAll(id = "text")
print(allText[0].get_text())
本文标题:2.2 再端一碗BeautifulSoup
本文链接:https://www.haomeiwen.com/subject/capgdctx.html
网友评论