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

像这样的文章要怎么爬取?

  •  
  •   LeCent · 2018-07-04 20:53:12 +08:00 · 2044 次点击
    这是一个创建于 2094 天前的主题,其中的信息可能已经有所发展或是发生改变。

    Snipaste_2018-07-04_20-46-21.png

    右上选择月份,显示该月份的最后一篇,然后往前翻

    http://www.sandeechan.com/blog/?m=200707

    3 条回复    2018-07-05 10:37:28 +08:00
    DrSpencerReid
        1
    DrSpencerReid  
       2018-07-05 09:29:24 +08:00
    看 url 也能看出来怎么抓了。。。。。。http://www.sandeechan.com/blog/?m=200707&paged=3
    liuguichao
        2
    liuguichao  
       2018-07-05 09:30:16 +08:00
    定位 html 标记,使用 xpath 提取 option value。

    <select id="archives-dropdown-2" name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">

    <option value="">選擇月份</option>
    <option value="http://www.sandeechan.com/blog/?m=201103"> 2011 年 三月 &nbsp;(31)</option>
    <option value="http://www.sandeechan.com/blog/?m=201102"> 2011 年 二月 &nbsp;(28)</option>
    <option value="http://www.sandeechan.com/blog/?m=201101"> 2011 年 一月 &nbsp;(31)</option>
    <option value="http://www.sandeechan.com/blog/?m=201012"> 2010 年 十二月 &nbsp;(31)</option>

    </select>
    RicardoScofileld
        3
    RicardoScofileld  
       2018-07-05 10:37:28 +08:00
    直接从页面固定位置获取下一页的 url 不就好了吗,然后接着请求下一页
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1459 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 17:24 · PVG 01:24 · LAX 10:24 · JFK 13:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.