Beautiful Soup 4.2.0 文檔:https://www.crummy.com/software/BeautifulSoup/bs4/doc/index.zh.html
2021-07-19
for t in soup.find_all('a'): # for循環(huán)遍歷所有a標簽,并把返回列表中的內容賦給t
print('t的值是:', t) # link得到的是標簽對象
print('t的類型是:', type(t))
print('a標簽中的href屬性是:', t.get('href')) # 獲取a標簽中的url鏈接
print('t的值是:', t) # link得到的是標簽對象
print('t的類型是:', type(t))
print('a標簽中的href屬性是:', t.get('href')) # 獲取a標簽中的url鏈接
2020-01-14
之前講過的這個方式
html = urlopen("https://en.wikipedia.org/robots.txt").read().decode("utf-8")
print(html)
爬出來的結果,似乎還更有秩序一些?
html = urlopen("https://en.wikipedia.org/robots.txt").read().decode("utf-8")
print(html)
爬出來的結果,似乎還更有秩序一些?
2019-11-30
我測試使用story = soup.find( {'class':'story'}) 返回None,使用
story = soup.find( class_='story') 可以正常返回結果
用的是python 3.7
story = soup.find( class_='story') 可以正常返回結果
用的是python 3.7
2018-09-30
我根據(jù)老師的代碼,返回的結果是json字符串,不是HTML,不過json更好了,都是干凈的數(shù)據(jù)
2018-09-30
如果安裝完畢后還是找不到bs4 直接在 PyCharm 的terminal命令行里面輸入 pip install bs4 完美解決
2018-09-23