简体   繁体   English

WebScraping 使用 BS4,AttributeError 使用 Find_all

[英]WebScraping With BS4, AttributeError with Find_all

This is the code im running.这是我正在运行的代码。

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')

And when i run it the output is当我运行它时,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'

Here is error, use soup=BeautifulSoup(r.text,"lxml") instead of这是错误,请使用soup=BeautifulSoup(r.text,"lxml")代替

soup=bs4,BeautifulSoup(r.text,"xml")

BeautifulSoup use different parser details here parser description here BeautifulSoup 使用不同的解析器细节在这里解析器描述在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM