根据委托编号查询cabrbetc网站的样品信息

import requests
from bs4 import BeautifulSoup

text = “BETC-HJ-2024-P-00362”
url = “http://weixin.cabr-betc.com/gjwx/wxfind/findreport?prtnum=”+text
print(url)

发送 GET 请求获取网页内容

response = requests.get(url)

使用 BeautifulSoup 解析网页内容

soup = BeautifulSoup(response.text, ‘html.parser’)

查找报告编号

report_num_elem = soup.find(‘div’, class_=‘weui-cell__hd’, string=‘报告编号’)
if report_num_elem is not None:
report_num = report_num_elem.find_next(‘div’, class_=‘weui-cell__bd’).text[38:]
print(f"报告编号: {report_num}")
else:
print(“未找到报告编号元素”)

查找报告标题

report_title_elem = soup.find(‘div’, class_=‘weui-cell__hd’, string=‘报告标题’)
if report_title_elem is not None:
report_title = report_title_elem.find_next(‘div’, class_=‘weui-cell__bd’).text[38:]
print(f"报告标题: {report_title}")
else:
print(“未找到报告标题元素”)

查找委托单位

entrust_unit_elem = soup.find(‘div’, class_=‘weui-cell__hd’, string=‘委托单位’)
if entrust_unit_elem is not None:
entrust_unit = entrust_unit_elem.find_next(‘div’, class_=‘weui-cell__bd’).text[38:]
print(f"委托单位: {entrust_unit}")
else:
print(“未找到委托单位元素”)

查找样品名称

sample_name_elem = soup.find(‘div’, class_=‘weui-cell__hd’, string=‘样品名称’)
if sample_name_elem is not None:
sample_name = sample_name_elem.find_next(‘div’, class_=‘weui-cell__bd’).text[38:]
print(f"样品名称: {sample_name}")
else:
print(“未找到样品名称元素”)

查找规格型号和数量(假设它们在同一行显示)

spec_quantity_elem = soup.find(‘div’, class_=‘weui-cell__hd’, string=‘规格型号’)
if spec_quantity_elem is not None:
spec_quantity = spec_quantity_elem.find_next(‘div’, class_=‘weui-cell__bd’).text[38:]
print(f"规格型号和数量: {spec_quantity}")
else:
print(“未找到规格型号和数量元素”)

查找检验项目

test_items_elem = soup.find(‘div’, class_=‘weui-cell__hd’, string=‘检验项目’)
if test_items_elem is not None:
test_items = test_items_elem.find_next(‘div’, class_=‘weui-cell__bd’).text[38:]
print(f"检验项目: {test_items}")
else:
print(“未找到检验项目元素”)

查找报告日期

report_date_elem = soup.find(‘div’, class_=‘weui-cell__hd’, string=‘报告日期’)
if report_date_elem is not None:
report_date = report_date_elem.find_next(‘div’, class_=‘weui-cell__bd’).text[38:]
print(f"报告日期: {report_date}")
else:
print(“未找到报告日期元素”)

查找报告状态

report_status_elem = soup.find(‘div’, class_=‘weui-cell__hd’, string=‘报告状态’)
if report_status_elem is not None:
report_status = report_status_elem.find_next(‘div’, class_=‘weui-cell__bd’).text[38:]
print(f"报告状态: {report_status}")
else:
print(“未找到报告状态元素”)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值