[英]WebScraping With BS4, AttributeError with Find_all
這是我正在運行的代碼。
import bs4
import requests
from bs4 import BeautifulSoup
r=requests.get('https://finance.yahoo.com/quote/SAS.ST/?guccounter=1')
soup=bs4,BeautifulSoup(r.text,"xml")
soup.find_all('div')
當我運行它時,output 是
> Traceback (most recent call last): File
> "/Users/darre/Desktop/script.py3", line 8, in <module>
> bi=soup.find_all('div') AttributeError: 'tuple' object has no attribute 'find_all'
這是錯誤,請使用soup=BeautifulSoup(r.text,"lxml")
代替
soup=bs4,BeautifulSoup(r.text,"xml")
BeautifulSoup 使用不同的解析器細節在這里解析器描述在這里
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.