无法在scrapy python中提取div html内容

bfnvny8b  于 2022-11-09  发布在  Python
关注(0)|答案(1)|浏览(164)

我正在废弃此URL中的一些数据
我想提取描述html div内容

这是我的代码

response.xpath("//*[@id='tab-description']/p").extract()

但是它返回额外普通数据。

我希望输出应该像这样

<p>    <strong>Brand Name: </strong>NoEnName_Null  <br>  <strong>Material: </strong>Cloth  <br>  <strong>Warning: </strong>2+  <br>  <strong>Function: </strong>Cooperation/Interpersonal Relations Developing  <br>  <strong>Dimensions: </strong>2/3/4/5/6 M  <br>  <strong>Design: </strong>Other  <br>  <strong>Age Range: </strong>&gt; 3 years old  <br>  <strong>Sports: </strong>Gymnastics  <br>  <strong>Type: </strong>Other  <br>  <strong>Gender: </strong>Unisex  <br>  <strong>Diameter: </strong>2/3/4/5/6 M  <br>  <strong>Material: </strong>210T Polyester fabric, 450mm water proof  <br>  <strong>Color: </strong>as the photo  <br>  <strong>handle number: </strong>8-28   </p>
bejyjqdl

bejyjqdl1#

from bs4 import BeautifulSoup
import requests

r = requests.get('https://bbdealz.com/product/funny-sports-game-2m-3m-4m-5m-6m-diameter-outdoor-rainbow-umbrella-parachute-toy-jump-sack-ballute-play-game-mat-toy-kids-gift/')
soup = BeautifulSoup(r.text, 'html.parser')
info = soup.select_one('#tab-description').select_one('p')
print(info)

相关问题