Python 我能';无法通过BeautifulSoup查找信息
我想做一个网址的网页抓取,但当我使用BeautifulSoup时,我找的一些信息没有找到,但它们是在原始的html中。如果打印(html_页面),我有我需要的所有信息,但当输出时,没有这些信息,当我尝试直接在html_页面上搜索时,会发生以下错误:Python 我能';无法通过BeautifulSoup查找信息,python,python-3.x,web-scraping,beautifulsoup,Python,Python 3.x,Web Scraping,Beautifulsoup,我想做一个网址的网页抓取,但当我使用BeautifulSoup时,我找的一些信息没有找到,但它们是在原始的html中。如果打印(html_页面),我有我需要的所有信息,但当输出时,没有这些信息,当我尝试直接在html_页面上搜索时,会发生以下错误: word = html_page word.find('name="produto-stock"') TypeError: argument should be integer or bytes-
word = html_page
word.find('name="produto-stock"')
TypeError: argument should be integer or bytes-like object, not 'str'
我的代码
为什么要将其括在引号中,请将其删除:-(
为什么要将其括在引号中,请将其删除:-(
我做了此更改,但错误仍然存在:参数应该是整数或类似字节的对象,而不是'str'我做了此更改,但错误仍然存在:参数应该是整数或类似字节的对象,而不是'str'
import requests
from bs4 import BeautifulSoup
url = 'https://www.maze.com.br/produto/tenis-puma-suede-classic-azul-marinho/4513515'
res = requests.get(url)
html_page = res.content
soup = BeautifulSoup(html_page, 'html.parser')
text = soup.find_all(text=True)
output = ''
blacklist = [
'noscript',
'header',
'html',
'meta',
'head',
'input',
'script',
]
for t in text:
if t.parent.name not in blacklist:
output += '{} '.format(t)
word = output
word.find('produto-stock')
word = html_page
word.find("produto-stock")