我有一个html文件,我尝试使用find方法从此文件返回获取的数据,这是我的代码
更新:我在find()方法之后删除了.text,它返回None!但我确定该值在文件中
from bs4 import BeautifulSoup
r= open('D:\IT\programming\Python\Data-science\WebScraping\ParseFiles\\test.html', encoding="utf-8")
soup = BeautifulSoup(r, 'html.parser').text
data = soup.find('span', class_='a-column a-span4 a-text-right a-span-last')
print(data)
它返回此错误:
Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/web_scraping/get_book_price.py", line 13, in <module>
data = soup.find('span', class_='a-column a-span4 a-text-right a-span-last').span
TypeError: find() takes no keyword arguments