第二篇学习笔记的链接为:https://blog.csdn.net/Nyte2018/article/details/88761489
这一篇是接上次关于第二章的学习
1、标签处理
先来看下面代码1:
from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen("http://www.pythonscraping.com/pages/page3.html")
bsObj = BeautifulSoup(html,"html.parser")
for sibling in bsObj.find("table",{
"id":"giftList"}).tr.next_siblings:
print(sibling)
这段代码会打印产品列表里的所有行的产品,第一行表格标题除外。BeautifulSoup 的 next_siblings() 函数,只调用后面的兄弟标签。例如,如果我们