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
sundays
V2EX  ›  Python

用循环爬网站子页面, requests,bs4,有什么要注意的么?

  •  
  •   sundays · 2017-03-09 09:52:47 +08:00 · 2112 次点击
    这是一个创建于 2576 天前的主题,其中的信息可能已经有所发展或是发生改变。

    可能是我没配对环境,反正 scrapy 现在用不了,就只能写正常脚本爬,除了加 time.sleep 还有啥注意事项啊,没用过几次 requests 库...

    3 条回复    2017-03-09 23:48:53 +08:00
    freeminder
        1
    freeminder  
       2017-03-09 10:09:41 +08:00
    换 UA ,有条件就换 IP ,最好把不是必要的 BS4 解析移出去,比如最终需要的那个页面先别做结构化解析,保留 html 就好。另外注意列表页的互斥,尽量在爬列表页的时候保证列表的内容也没什么重复最好。
    chendajun
        2
    chendajun  
       2017-03-09 10:30:32 +08:00
    配置 scrapy 环境, linux 比 windows 简单些。
    Akkuman
        3
    Akkuman  
       2017-03-09 23:48:53 +08:00 via Android
    soup 解析,一般可以一行写完,用列表推导式
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1136 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 22:57 · PVG 06:57 · LAX 15:57 · JFK 18:57
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.