Python 爬虫框架pyspider尝试
2016-07-09 16:24
441 查看
安装pyspider
pyspider可以做什么,在这里我不打算多说, 官方有详细文档介绍:官方文档:http://docs.pyspider.org/en/latest/
下面直接上干货:
要准备的东西:
消息中间件 (all模式必选):rabbitmq、beanstalk、kombu、redis都可以
rabbitmq: http://www.rabbitmq.com/download.html 需依赖erlang: http://www.erlang.org/downloads
数据库 (可选):
mysql
mysql-connector 包
PhantomJS (可选)
启动配置:
pyspider.conf (名字任意起){
“taskdb”: “mysql+taskdb://username:password@host:port/pyspider_db”,
“projectdb”: “mysql+projectdb://username:password@host:port/pyspider_db”,
“resultdb”: “mysql+resultdb://username:password@host:port/pyspider_db”,
“message_queue”: “amqp://username:password@host:port/%2F”,
“webui”: {
“username”: “some_name”,
“password”: “some_passwd”,
“need-auth”: true
}
}
踩过的坑
点击Run之后,Python崩溃这个是因为Python是64位造成的, 换成32位后解决
HTTP 599: SSL certificate problem: self signed certificate in certificate chain
这个错误会发生在请求 https 开头的网址,SSL 验证错误,证书有误。
解决方法:在 crawl 方法中加入忽略证书验证的参数,validate_cert=False, 也可以加到全局crawl_config中
unknow project: xxx
先将状态改成Debug或者Running, 再点击Run
connect to scheduler rpc error: error(10061, ”)
如果用all模式启动, pyspider各模块将处于不同的子进程中, 需要依赖消息中间件才能工作
No module named mysql.connector
需要mysql-connector驱动包
all模式启动:pyspider [-c xxx.conf] all
待续
相关文章推荐
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- install and upgrade scrapy
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- 爬虫笔记
- Python中zip()函数用法举例
- Python中map()函数浅析
- Python将excel导入到mysql中
- Python在CAM软件Genesis2000中的应用
- 使用Shiboken为C++和Qt库创建Python绑定
- python学习——循环