Python爬虫之selenium各种注意报错
刚刚写完第一个selenuim+BeautifulSoup实战爬虫 爬淘宝。发现代码写完后不加for 翻页的时候没什么问题 解析 操作 都没问题 也就是说第一页 的内容 完好
pagebtn=wait .until(EC.presence_of_element_located((By.CSS_SELECTOR, "#mainsrp-pager > div > div > div > div.form > span.btn.J_Submit")))
soup=BeautifulSoup(browser.page_source,'lxml')
info=soup.find(attrs={'id':'mainsrp-itemlist'})
imglist=info.find_all(attrs={'class':'J_ItemPic img'})
pricelist=info.find_all('strong')
locationlist=info.find_all(attrs={'class':'location'})
shopnamelist=info.find_all(attrs={'class':'shopname J_MouseEneterLeave J_ShopInfo'})
for imgsrcname,price,location, shopname in zip(imglist,pricelist,locationlist, shopnamelist):
data={}
data={
'name':imgsrcname.attrs['alt'],
'imgsrc':imgsrcname.attrs['src'],
'prick':price.get_text(),
'location':location.get_text(),
'shopname':shopname.contents[3].get_text()
}
collection.insert(data) pagebtn.click()
运行完好 数据库也有数据
可是需要频繁点击翻页的时候
对于刚刚学习的人 一大串英文 显然看不懂 百度翻译 查
检查代码,
也加了等待啊 显示等待
为什么还是报错
说实话我不知道,,
在前面+了一个sleep(5)让他慢点操作 就可以了 完美翻页100
总结:
我觉得在使用selenuim的时候 尽可能的少操作网页(输入,点击),尽量模拟人的行为 机器运行太快 浏览器可能反应不过来。
Python爬虫之selenium各种注意报错的更多相关文章
- python脚本中selenium启动浏览器报错os.path.basename(self.path), self.start_error_message) selenium.common.excep
在python脚本中,使用selenium启动浏览器报错,原因是未安装浏览器驱动,报错内容如下: # -*- coding:utf-8 -*-from selenium import webdrive ...
- python爬虫,使用urllib2库报错
urllib2发生报错URLError: <urlopen error [Errno 10061]:首先检查网址是否正确其次如果报这种错误,是因为ie里设置了代理,取消即可, 步骤: 打开IE浏 ...
- python中用selenium调Firefox报错问题
python在用selenium调Firefox时报错: Traceback (most recent call last): File "G:\python_work\chapter11 ...
- python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?
python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...
- Selenium Grid 运行报错 Exception thrown in Navigator.Start first time ->Error forwarding the new session Empty pool of VM for setup Capabilities
Selenium Grid 运行报错 : Exception thrown in Navigator.Start first time ->Error forwarding the new se ...
- selenium执行js报错
selenium执行js报错 Traceback (most recent call last): dr.execute_script(js) File "C:\Python27\l ...
- [Python爬虫]使用Selenium操作浏览器订购火车票
这个专题主要说的是Python在爬虫方面的应用,包括爬取和处理部分 [Python爬虫]使用Python爬取动态网页-腾讯动漫(Selenium) [Python爬虫]使用Python爬取静态网页-斗 ...
- Python 爬虫利器 Selenium 介绍
Python 爬虫利器 Selenium 介绍 转 https://mp.weixin.qq.com/s/YJGjZkUejEos_yJ1ukp5kw 前面几节,我们学习了用 requests 构造页 ...
- Python爬虫之selenium的使用(八)
Python爬虫之selenium的使用 一.简介 二.安装 三.使用 一.简介 Selenium 是自动化测试工具.它支持各种浏览器,包括 Chrome,Safari,Firefox 等主流界面式浏 ...
随机推荐
- ReSharper2018破解详细方法
下载地址: 主程序官网下载链接:https://download.jetbrains.com/resharper/ReSharperUltimate.2018.3.3/JetBrains.ReShar ...
- FreeHttp1.1升级说明
一.升级方法 下载新版本插件 https://files.cnblogs.com/files/lulianqi/FreeHttp1.1.zip 或 http://lulianqi.com/file/ ...
- C语言报错:error: expected ‘while’ at end of input } ^
在建线程池过程当中遇见上图所示错误: 解决方法: Linux中定义: SYNOPSIS #include <pthread.h> void pthread_cleanup_push(voi ...
- SSM(Spring + Springmvc + Mybatis)框架面试题
JAVA SSM框架基础面试题https://blog.csdn.net/qq_39031310/article/details/83050192 SSM(Spring + Springmvc + M ...
- ansible-playbook(node_exporter)
roles/node_exporter/tasks/main.yml - name: copy package copy: src=node_exporter-0.17.0.linux-amd64.t ...
- Idea在@Autowired注入时报错
Could not autowire. No beans of 'UserDao' type found 如图,是因为idea检测能力太强,一旦没有找到实现类就会报错,但是我试了,这里其实是注入进来了 ...
- 存储类&作用域&生命周期&链接属性
链接属性 (1)大家知道程序从源代码到最终可执行程序,经历的过程:编译.链接. (2)编译阶段就是把源代码搞成.o目标文件,目标文件里面有很多符号和代码段.数据段.bss段等分段.符号就是编程中的变量 ...
- Educational Codeforces Round 63 (Rated for Div. 2) C. Alarm Clocks Everywhere gcd
题意:给出一个递增的时间序列a 给出另外一个序列b (都是整数) 以b中任选一个数字作为间隔 自己从1开始任选一个时间当成开始时间 输出选择的数字标号以及 开始时间 思路 直接求间隔的公共gc ...
- Luogu3768简单的数学题
题目描述 题解 我们在一通化简上面的式子之后得到了这么个东西. 前面的可以除法分块做,后面的∑T2∑dµ(T/d)是积性函数,可以线性筛. 然后这个数据范围好像不太支持线性筛,所以考虑杜教筛. 后面那 ...
- Codeforces Round #544 (Div. 3) D F1 F2
题目链接:D. Zero Quantity Maximization #include <bits/stdc++.h> using namespace std; #define maxn ...