推荐学习书目
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
whatisnew
V2EX  ›  Python

爬虫,通用型,独立型

  •  
  •   whatisnew · May 1, 2015 · 4070 views
    This topic created in 4107 days ago, the information mentioned may be changed or developed.

    大家在写爬虫的时候是写成通用型,还是独立型呢?

    比如,通用型:一套规则对应一个爬虫
    比如,独立型:一个规则对应一个爬虫

    比如,要爬100〜10000个不等的网站,用哪种方案比较合适呢?

    之所以,这么问,是因为不管是通用型还是独立型,每一个抓取规则都要人肉分析 dom 结构的,如果每一个都要人肉分析的话,那么通用和独立的区别就只有程序结构和代码维护方面的区别了。

    8 replies    2015-05-03 12:32:27 +08:00
    est
        1
    est  
       May 1, 2015   ❤️ 1
    爬虫专家 @binux 他是pyspider作者。

    人肉分析DOM结构已经过时了。现代的方式是直接pick DOM元素自动生产xpath或者css selector或者正则或者whatever。
    webflier
        2
    webflier  
       May 2, 2015
    @est 直接pick DOM元素自动生产xpath或者css selector或者正则或者whatever
    这是有什么现成工具吗?求指导
    sohoer
        3
    sohoer  
       May 2, 2015 via iPhone   ❤️ 1
    看我的
    whatisnew
        5
    whatisnew  
    OP
       May 2, 2015
    再问:

    请求头,是伪装成 baidu 呢?还是伪装成 ie8 呢,还是伪装成 chrome 呢。

    header 头里的:
    Accept:
    Accept-Encoding:

    之类的如何写可以提高抓取成功率呢?(目前发现有一些会对 Googlebot 和 Baiduspider 和 正常浏览器提供不同的内容,然后 dom 规则就失效了!x... )
    Owenjia
        6
    Owenjia  
       May 3, 2015 via Android
    @est 遇到过一个超复杂超乱的页面,最后实在没办法就去掉所有标签直接 split 了……
    thedarkside
        7
    thedarkside  
       May 3, 2015
    不明觉历~~
    est
        8
    est  
       May 3, 2015
    @Owenjia 是啊。。有的时候只能简单粗暴。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5362 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 08:00 · PVG 16:00 · LAX 01:00 · JFK 04:00
    ♥ Do have faith in what you're doing.