使用Selenium浏览器自动抓取cabrbetc网站的样品信息

from selenium import webdriver

from bs4 import BeautifulSoup

import time

'''

#根据委托编号创建查询网址

text = "BETC-HJ-2024-P-00362"

url = "http://weixin.cabr-betc.com/gjwx/wxfind/findreport?prtnum="+text

print(url)

'''

将委托单位名称转化成utf-8格式,并用%连接转化后16进制,导入cabr-betc报告的查询网址url中

text = "中寓装配(江苏)新材料有限公司"

utf8_encoded_text = text.encode('utf-8')

hex_representation = '%'.join(hex(b)2: for b in utf8_encoded_text)

#print(hex_representation)

url = "http://weixin.cabr-betc.com/gjwx/wxfind/findreport?prtnum=\&xmname=\&wtunit=%"+hex_representation+"\&page=1\&rows=1000"

print(url)

创建 Chrome 浏览器驱动实例

driver = webdriver.Chrome()

打开指定网址

driver.get(url)

等待页面加载完成,可根据实际情况调整等待时间

time.sleep(5)

获取页面源代码

page_source = driver.page_source

使用 BeautifulSoup 解析页面源代码

soup = BeautifulSoup(page_source, 'html.parser')

查找所有报告编号元素并打印

report_numbers = soup.find_all('div', class_='weui-cell__bd')

for number in report_numbers:

print(number.text)

关闭浏览器驱动

driver.close()

相关推荐
“AI国潮设计-小江”7 分钟前
【Python/SDXL实战】潮汕国潮IP视觉落地:普宁美食猫IP & 创意甜品设计(附ComfyUI工作流思路)
开发语言·人工智能·python·prompt·aigc
Allen_LVyingbo30 分钟前
医疗人工智能项目全生命周期管理系统:监管知识建模、工程实现与实证评估(下)
大数据·数据库·人工智能·python·自然语言处理·自动化
wuhuhuan1 小时前
Case Generator 平台升级
python·测试工具·自动化
RobinDevNotes1 小时前
用 Profile 揪出大模型训练性能瓶颈
python·性能优化
李航19831 小时前
用 DeepDraw 几何引擎开发建筑设计软件(六):创建画线工具
python·软件构建
AI 编程助手GPT1 小时前
Python 备份 SQLite:为什么复制了 .db,恢复后还是少数据?
人工智能·python·ai·chatgpt
狗都不学爬虫_1 小时前
AI逆向 - 天御无感点击验证(补+纯)
爬虫·python·网络爬虫
柒儿吖1 小时前
SSCom 重构全记录:用 Rust 把串口调试助手送上鸿蒙 PC、macOS、Windows和Linux
测试工具·rust·harmonyos
529宝宝起名网2 小时前
用 Python 开发历史名字查询与起名灵感工具:从古籍人物数据库到名字文化故事生成
开发语言·前端·python
用户298698530142 小时前
Python 将 HTML 转换为 Word 文档的实践指南
python·html·api