【发布时间】:2020-07-02 01:18:03
【问题描述】:
我正在尝试从网站解析一些信息,但遇到了一个小问题,我需要的信息不会打印出来,并且在我需要值时仅显示 [](例如来自提供的源代码的 3。我会需要一些帮助才能使其正常工作。希望这里有人可以帮助我并协助解决这个问题。
最好的问候。
import re
import requests
from bs4 import BeautifulSoup
url_to_parse = "https://www.webpage.com"
response = requests.get(url_to_parse)
response_text = response.text
soup = BeautifulSoup(response_text, 'lxml')
#print(soup.prettify())
ragex = re.compile('c76a6')
content_lis = soup.find_all('button', attrs={'class': ragex})
print(content_lis)
source: <button class="c76a6" type="button" data-test-name="valueButton"><span class="_5a5c0" data-test-name="value">3</span></button>
【问题讨论】:
标签: python beautifulsoup python-requests python-re