首先pyspider all启动pyspider的所有服务,然后访问http://localhost:5000创建一个爬虫任务:taobaomm,点开任务链接编辑http://localhost:5000/debug/taobaomm,默认模板:
 
右侧为代码编辑区,可以在crawl_config里做一些配置,具体可以参考官网API文档:http://docs.pyspider.org/en/latest/apis/self.crawl/#validate_cert,Handler共实现了三个函数,大致可以知道从函数on_start开始,爬到后回调index_page处理,index_page函数中可以解析出超链接继续爬取,并将爬到的内容回调给detail_page处理,detail_page里可以解析出具体想要爬取的信息。
 
左侧为调试运行栏,下面的向左向右箭头用于切换步骤,run按钮可以运行指定的步骤。编写脚本抓取https://mm.taobao.com/json/request_top_list.htm?page=1里的信息(源码后面会全部贴出),出现错误:
 
[E 160329 11:32:22 base_handler:194] HTTP 599: SSL certificate problem: self signed certificate in certificate chain
    Traceback (most recent call last):
File "C:\Python27\lib\site-packages\pyspider\libs\base_handler.py", line 187, in run_task
result = self._run_task(task, response)
File "C:\Python27\lib\site-packages\pyspider\libs\base_handler.py", line 166, in _run_task
response.raise_for_status()
File "C:\Python27\lib\site-packages\pyspider\libs\response.py", line 183, in raise_for_status
raise http_error
HTTPError: HTTP 599: SSL certificate problem: self signed certificate in certificate chain
 
网上有遇到类似错误的:
 
一开始搜索“HTTPError: HTTP 599: SSL certificate problem: self signed certificate in certificate chain”这个错误,找到这个:HTTP 599: SSL certificate problem: self signed certificate in certificate chain #362,大概知道是跟curl的证书有关系。
于是下载了curl的windows版本,下载路径: https://curl.haxx.se/download.html

  

解压后是两个文件:ca-bundle.crt和curl.exe,也知道https的请求需要证书,也知道ca-bundle.crt就是这个证书,关键是不知道怎么让pyspider使用起来。
 
先验证一下,在pycharm里编写脚本:
import pycurl

#创建一个同libcurl中的CURL处理器相对应的Curl对象
c = pycurl.Curl() c.setopt(pycurl.URL, 'https://mm.taobao.com/json/request_top_list.htm?page=1') # 设置证书
# c.setopt(pycurl.CAINFO, 'C:\\Python27\\curl\\curl-ca-bundle.crt') #执行上述访问网址的操作 c.perform()

运行后输出错误:

Traceback (most recent call last):
  File "F:/PycharmProjects/test/pycurlStudy.py", line 90, in <module>
    c.perform()
pycurl.error: (60, 'SSL certificate problem: self signed certificate in certificate chain')
 
可以看到错误信息是和上面的一模一样的(错误码不一样这个不重要,可能pyspider有二次封装),然后把上面的验证代码的注释去掉,也就是设置一下证书,再次运行,OK!

 
思路是对了,关键是不知道怎么让pyspider使用起证书ca-bundle.crt。
 
后来搜索到pyspider的官网API文档:http://docs.pyspider.org/en/latest/apis/self.crawl/#validate_cert
发现有一个标记可以用validate_cert
validate_cert - For HTTPS requests, validate the server’s certificate? default: True
 
也就是这样使用self.crawl(url, callback=self.index_page, validate_cert=False)
但是运行依然报错,提示validate_cert不存在该key,草泥马!
然后通篇搜索D:\Python27\Lib\site-packages\pyspider目录根本没有发现validate_cert,草泥马!
但是网上搜索能找到,就是在github上,也就是说最新的pyspider源码里是有validate_cert的,然后怀疑自己的pyspider安装的是否是最新版的,当天才安装的,应该不至于,于是pip install --upgrade pyspider也提示已经是最新版了。
 
那么只有一个可能了:
pyspider最新源码和最新文档里都有,但是可能还未更新到最新的安装包里。于是先git下来最新的pyspider源码,把
C:\Python27\Lib\site-packages\pyspider-0.3.10.dev0-py2.7.egg目录下的pyspider整个文件夹删除,用git下的源码里的pyspider整体复制过去,重启pyspider all,再次浏览器中运行,成功!

PySpider 框架爬虫错误 HTTP 599: SSL certificate problem: unable to get local issuer certificate解决方案的更多相关文章

  1. HTTP 599: SSL certificate problem: unable to get local issuer certificate错误

    自己在用 PySpider 框架爬虫运行代码后时出现 HTTP 599: SSL certificate problem: unable to get local issuer certificate ...

  2. curl: (60) SSL certificate problem: unable to get local issuer certificate 错误

    今天同事做微信管理的项目,请求接口返回如下错误SSL certificate problem: unable to get local issuer certificate. 此问题的出现是由于没有配 ...

  3. git中的SSL certificate problem: unable to get local issuer certificate错误的解决办法

    我们在使用git初始化一个项目时,尤其是通过git submodule update --init --remote初始化子模块时,可能会遇到下面这个错误: fatal: unable to acce ...

  4. Git错误:unable to access 'https://git.voicegu.com/qa/qa.git/': SSL certificate problem: unable to get local issuer certificate

    fatal: unable to access 'https://git.voicegu.com/qa/qa.git/': SSL certificate problem: unable to get ...

  5. ...cURL error 60: SSL certificate problem: unable to get local issuer certificate...

    问题描述: 在做PHP爬虫的时候, 安装了 guzzle 和 dom-crawler 之后, 调用的时候出现问题, 如下 报错内容:  Fatal error: Uncaught GuzzleHttp ...

  6. SSL certificate problem: unable to get local issuer certificate 的解决方法

    今天在进行微信开发获取微信Access_Token时,使用到了php的curl库, 在敲完代码后获取token失败,经过各种排查错误,到了下面这一步 SSL certificate problem: ...

  7. 【error】git clone: SSL certificate problem: unable to get local issuer certificate

    报错: $ git clone https://github.XXX.git Cloning into 'XXX'... fatal: unable to access 'https://github ...

  8. cURL error 60: SSL certificate problem: unable to get local issuer certificate 解决方法

    微信开发的时,请求接口报错如下: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see ...

  9. 使用git克隆仓库到本地报错:SSL certificate problem: unable to get local issuer certificate

    第一次使用Git工具克隆仓库,使用的是HTTPS链接,失败了.发现是因为通过HTTPS访问时,如果服务器上的SSL证书未经过第三方机构认证,Git就会报错. 解决方法:通过命令关闭验证 git con ...

  10. SSL certificate problem unable to get local issuer certificate解决办法

    SSL certificate problem unable to get local issuer certificate 解决办法: 下载:ca-bundle.crt 将它放在自己的wamp或者x ...

随机推荐

  1. poj 3280(区间DP)

    Cheapest Palindrome Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7869   Accepted: 38 ...

  2. Jmeter----读取excel表中的数据

    Jmeter 读取excel数据使用的方法是使用CSV Data Set Config参数化,之后使用BeanShell Sampler来读取excel表中的数据 第一步.查看所需的接口都要哪些字段和 ...

  3. Go语言标准包之json编码

    标准的就简单通用. package main import ( "encoding/json" "fmt" "log" ) func mai ...

  4. Go语言有缓冲和无缓冲通道实现样例

    感觉可以,但不好用. 应该有封装程序更高的包包吧. package main import ( "math/rand" "fmt" "time&quo ...

  5. PHP生成随机字符串与唯一字符串

    代码如下: <?php /* * 生成随机字符串 * @param int $length 生成随机字符串的长度 * @param string $char 组成随机字符串的字符串 * @ret ...

  6. hdu5735

    很美妙的一题 官方题解 http://www.cnblogs.com/duoxiao/p/5777632.html 感觉有meet in middle的思想 #include<bits/stdc ...

  7. SQL练习总结

    [SQL语句练习] 1. 表1: Person +-------------+---------+ | 列名 | 类型 | +-------------+---------+ | PersonId | ...

  8. 北邮校赛 I. Beautiful Array(DP)

    I. Beautiful Array 2017- BUPT Collegiate Programming Contest - sync 时间限制 1000 ms 内存限制 65536 KB 题目描述 ...

  9. 29、Flask实战第29天:cms用户名渲染和注销功能实现

    这节来完成用户名渲染和注销的功能,目前用户名在前端页面是写死的,我们需要动态的展示出来 用户名渲染 实现用户名动态展示,其中一种方法就是在视图函数,根据session信息,获取到user id,通过该 ...

  10. 【BFS】The New Villa

    [poj1137] The New Villa Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 1481   Accepted ...