V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
linzhi
V2EX  ›  Python

写了一个简单的分布式定下爬虫

  •  
  •   linzhi · 2017-04-18 14:48:45 +08:00 · 2584 次点击
    这是一个创建于 2558 天前的主题,其中的信息可能已经有所发展或是发生改变。
    + 待抓取和已抓取(存放 url 的 hash )的 url 队列存储在 redis
    + 抓取结果放在 mongo
    + spider 和 master 之间用 rpc 框架通信( thrift 的 python 版本 thriftpy )

    目前实现了是抓取点评 poi 详情页面的名称 地址 电话 3 个字段,后续再继续其他定下抓取的功能


    项目地址: https://github.com/linzhi/minerva

    爬虫的稳定性方面还有待提升,后续慢慢优化
    第 1 条附言  ·  2017-04-19 00:37:49 +08:00
    更新了抓取点评 POI 的城市和坐标的逻辑
    第 2 条附言  ·  2017-04-20 11:43:51 +08:00
    有个问题请教下大家,仿照 https://github.com/xchaoinfo/fuck-login 写的知乎模拟登录,一直报验证码无效的 msg ,即使用个错误的密码也是报这个, 不知道为啥呢
    7 条回复    2017-04-24 10:47:33 +08:00
    linzhi
        1
    linzhi  
    OP
       2017-04-20 11:42:58 +08:00
    有个问题请教下大家,仿照 https://github.com/xchaoinfo/fuck-login 写的知乎模拟登录,一直报验证码无效的 msg ,即使用个错误的密码也是报这个,代码在 https://github.com/linzhi/minerva/blob/master/minerva/zhihu.py ,不知道为啥呢
    linzhi
        2
    linzhi  
    OP
       2017-04-20 13:06:27 +08:00
    知道原因了。。。获取验证码的 url https://www.zhihu.com/captcha.gif?r=1492661961962&type=login ,即使中间的参数 r (时间戳)是一样的,获取到的验证码也不一样
    linzhi
        3
    linzhi  
    OP
       2017-04-22 11:41:22 +08:00
    再次更新。。抓取知乎的问题&答案 不需要模拟登陆。。。。之前方向错了
    creatorYC
        4
    creatorYC  
       2017-04-23 16:11:15 +08:00
    我想问问为什么我写的爬虫运行一段时间就会报 requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",)),用的 python 和 requests 库,我没有使用多线程,在请求之前都添加了 time.sleep(0.5) ,按说不至于请求太频繁啊,请问这个问题该怎么解决啊!谢谢了,找了好久答案也没辙
    linzhi
        5
    linzhi  
    OP
       2017-04-23 16:24:58 +08:00
    creatorYC
        6
    creatorYC  
       2017-04-23 16:33:27 +08:00
    @linzhi 我看了那个解决方案,应该不是那个问题,要贴异常代码吗?还是程序代码?
    Traceback (most recent call last):
    File "zhihuSprider.py", line 306, in <module>
    sprider.bfs_search()
    File "zhihuSprider.py", line 286, in bfs_search
    self.analyze_user(user_url, followee_url, follower_url)
    File "zhihuSprider.py", line 155, in analyze_user
    result = json.loads(self.get_user_data(user_url))
    File "zhihuSprider.py", line 144, in get_user_data
    response = self.session.get(url, headers=self.headers)
    File "D:\Python27\lib\site-packages\requests\sessions.py", line 501, in get
    return self.request('GET', url, **kwargs)
    File "D:\Python27\lib\site-packages\requests\sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
    File "D:\Python27\lib\site-packages\requests\sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
    File "D:\Python27\lib\site-packages\requests\adapters.py", line 473, in send
    raise ConnectionError(err, request=request)
    requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))
    linzhi
        7
    linzhi  
    OP
       2017-04-24 10:47:33 +08:00
    @creatorYC 有代码链接么
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5235 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 09:19 · PVG 17:19 · LAX 02:19 · JFK 05:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.