import requests
page = requests.get("https://www.proflowers.com/mothers-day-flowers-mdf?navContent=T%3aMother%27s+Day%3aBest+Sellers&navLocation=T%3a1-10%3a1-19")
from bs4 import BeautifulSoup
soup = BeautifulSoup(page.content, 'html.parser')
for desc in soup.find_all('div', class_="product-summary__short-description"):
print(desc.p.get_text())结果:
有时候农民才是最了解的!卡利送的激进玫瑰!相当于心眼表情的花。新的母亲节座右铭。有足够的勇气发表一个重要的声明。为你的榜样,你的英雄。彩色玫瑰!为了一份坚定而强烈的爱。20%的购买价格捐赠给没有孩子的饥饿。最高级的粉笔。从我们的高级玫瑰收藏天堂绽放。带着农场新鲜的玫瑰多走一英里!灯光摄像机满意。当我们说所有的颜色时,我们指的是所有的颜色。美丽和糟糕的一天。彩色摩天轮。有时候美女会窃窃私语。柔软的薰衣草玫瑰。这个布克令人陶醉。
我想刮掉所有的产品“简短的描述”。有谁能帮我一下吗out..Thank你:)
发布于 2018-04-24 16:26:47
你可以得到这样的描述:
import requests
from bs4 import BeautifulSoup
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0',
}
page = requests.get(r"https://www.proflowers.com/mothers-day-flowers-mdf?navContent=T%3aMother%27s+Day%3aBest+Sellers&navLocation=T%3a1-10%3a1-19", headers=headers)
soup = BeautifulSoup(page.content, 'html.parser')
for desc in soup.find_all('div', class_="name"):
print(desc.a.get_text().strip())输出
One Dozen Rainbow Mother's Day Roses
Two Dozen Rainbow Mother's Day Roses
15 Multi-Colored Tulips for Mom
30 Multi-Colored Tulips for Mom with Brilliant Cut Glass Vase and Chocolates
12 Long Stemmed Rainbow Mother's Day Roses
...https://stackoverflow.com/questions/50004600
复制相似问题