使用bsObj python从网页导出标签名称
我想从网页中获取url目标的名称 这就是迄今为止我们所做的:使用bsObj python从网页导出标签名称,python,python-3.x,beautifulsoup,Python,Python 3.x,Beautifulsoup,我想从网页中获取url目标的名称 这就是迄今为止我们所做的: check ='https://www.zap.co.il/search.aspx?keyword='+'N3580-5092' r = requests.get(check) html = requests.get(r.url) bsObj = BeautifulSoup(html.content,'xml') storeName = bsObj.select_one('div.StoresLines div.BuyButtonsT
check ='https://www.zap.co.il/search.aspx?keyword='+'N3580-5092'
r = requests.get(check)
html = requests.get(r.url)
bsObj = BeautifulSoup(html.content,'xml')
storeName = bsObj.select_one('div.StoresLines div.BuyButtonsTxt')
结果是:
<div class="BuyButtonsTxt">
ב-<a aria-label="לקנייה ב-פיסי אונליין Dell Inspiron 15 3580
N3580-5092" href="/fs.aspx?pid=666473435&sog=c-pclaptop" id=""
target="_blank">פיסי אונליין</a>
</div>
ב-
我只需要href中的值:“פיסיאנ㪡ין”
怎么做 我必须将
bsObj=beautifulsop(html.content,'xml')
更改为bsObj=beautifulsop(html.content,'html.parser')
,因为“xml”无法为我找到标记
from bs4 import BeautifulSoup
import requests
check ='https://www.zap.co.il/search.aspx?keyword='+'N3580-5092'
r = requests.get(check)
html = requests.get(r.url)
bsObj = BeautifulSoup(html.content,'html.parser')
storeName = bsObj.select_one('div.StoresLines div.BuyButtonsTxt')
text = storeName.find('a').text
输出:
'פיסי אונליין'