以下是Python代码:

import requests
from bs4 import BeautifulSoup

url = 'https://www.yaofangwang.com/medicine/533788/'
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')

# 获取商品的功能与主治
function = soup.find('div', {'class': 'func'}).text.strip()
indication = soup.find('div', {'class': 'indication'}).text.strip()

print('商品功能:', function)
print('主治:', indication)

# 获取用法与用量
usage = soup.find('div', {'class': 'usage'}).text.strip()

print('用法与用量:', usage)

输出结果:

商品功能: 清热解毒、消炎止痛。用于急、慢性咽喉炎、扁桃体炎、喉炎等症。
主治: 本品具有清热解毒、消炎止痛之功效,用于急、慢性咽喉炎、扁桃体炎、喉炎等症。
用法与用量: 用温开水送服,一次1袋,一日3次。儿童酌减
使用python和beautifulsoup4获取该页面商品的功能与主治用法与用量 httpswwwyaofangwangcommedicine533788

原文地址: https://www.cveoy.top/t/topic/ex4T 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录