Python代码大全之selenium 从网页提出数据并存储到sqlite数据库(完整代码)
2023-09-11 14:18:32 时间
从页面获取数据
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver1= webdriver.Chrome()
url='http://www.guzicha'
driver1.get(url)
blist=[]
for i in range(1,8):
bh=driver1.find_elements_by_xpath('//*[@id="keypad"]/table/tbody/tr['+str(i)+']/td[2]/a')
for t in bh:
if t.text == '':
print('empty',t)
continue
para={}
para['bihua']=i
para['bstyle']=t.get_attribute('name')
para['bvalue']=t.text
blist.append(para)
提取子元素
# find_elements_by_xpath("./*") 找到所有子元素
# find_elements_by_xpath("./..") 找到父元素
qt=driver1.find_element_by_xpath('//*[@id="keypad"]/table/tbody/tr[8]/td[2]')
slist=qt.find_elements_b
相关文章
- python实现用户登陆(sqlite数据库存储用户信息)
- 【Python成长之路】python 基础篇 -- global/nonlocal关键字使用
- Python实现进程同步和通信
- python: easyocr的安装和使用(easyocr 1.6.2 / Python 3.7.15 )
- Python操作SQLite数据库的方法详解
- Python操作SQLite数据库
- 通过Python自动发邮件《生如夏花》
- Python 用推导式解决“七段码”问题
- 华为OD机试 - 数组组成的最小数字(Java & JS & Python)
- Python语言学习之打印输出那些事:python输出图表和各种吊炸天的字符串或图画、版权声明(如README.md)等之详细攻略
- Python之tkinter:动态演示调用python库的tkinter带你进入GUI世界(text.insert/link各种事件)
- Python语言学习:解决python版本升级问题集合(python2系列→Python3系列)导致错误的总结集合
- 从零开始学python | 使用Python映射,过滤和缩减函数:所有您需要知道的
- 【华为云技术分享】使用pdb调试python代码的方法
- 【Python成长之路】python 基础篇 -- global/nonlocal关键字使用
- python原类、类的创建过程与方法
- 爱啦爱啦,这三款最频繁使用的 Python 数据探索分析神器真香啊
- 值得收藏!这 100 个 Python 实战小项目真棒!
- 【SQLite备忘】sqlite设置自增字段
- Python编程:查看python语法中的关键字keyword
- Python: re.compile最短匹配模式,只取双引号内的值“
- 雅虎财经数据python 网络爬虫stock股票 用 Python 通过雅虎财经获取股票数据
- Python数模笔记-NetworkX(5)关键路径法
- Python 操作SQLite数据库