【发布时间】:2020-08-16 09:16:11
【问题描述】:
如何使用 beautifulsoup 检索突出显示的文本? 一个例子将是最好的答案,谢谢;)
编辑;这是代码
import requests
import pyperclip
from bs4 import BeautifulSoup
import time
url = 'https://sales.elhst.co/'
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36"}
site = requests.get(url, headers=headers)
site = str(site)
if site == "<Response [200]>":
print("Site is up..")
page = requests.get(url, headers=headers)
soup = BeautifulSoup(page.content, 'html.parser')
time.sleep(2)
target = soup.find("pp", id="copies")
print(target)
输出是:
Site is up..
<pp id="copies"></pp>
我想得到这个文本: https://imgur.com/a/JcTnbiw 有什么办法吗?
【问题讨论】:
-
请附上html代码而不是截图链接
标签: python beautifulsoup