V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
xiushenbuhuihui
V2EX  ›  Python

scrapy 框架中的 crawlspider 爬虫问题请教!

  •  
  •   xiushenbuhuihui · Jun 14, 2019 · 2152 views
    This topic created in 2523 days ago, the information mentioned may be changed or developed.
    创建了 scrapy 框架中的 crawlspider 抓取全网站信息时,网页源代码中的相对链接并没有被转化为绝对链接,导致抓取的整个网站信息不全,请教大神,该怎么办
    luanguang
        1
    luanguang  
       Jun 14, 2019
    用自带方法拼接
    ```
    response.urljoin()
    ```
    fank99
        2
    fank99  
       Jun 14, 2019
    我是这样的。。
    from urllib.parse import urljoin
    yield Request(url=urljoin(response.url, url), callback=)
    xiushenbuhuihui
        3
    xiushenbuhuihui  
    OP
       Jun 14, 2019
    @luanguang 您好,我把我的问题给你详细描述一下,请您帮我解决一下。
    用的是 crawlspider 爬取乐融商城全部的网站源代码,但是爬取到精选配件页面(全部分类选项里面)时,由于商品(“比如:乐视蓝牙耳机”)的链接只是相对的,结果导致无法爬取商品页面源代码
    xiushenbuhuihui
        4
    xiushenbuhuihui  
    OP
       Jun 14, 2019
    @fank99 您好,我把我的问题给你详细描述一下,请您帮我解决一下。
    用的是 crawlspider 爬取乐融商城全部的网站源代码,但是爬取到精选配件页面(全部分类选项里面)时,由于商品(“比如:乐视蓝牙耳机”)的链接只是相对的,结果导致无法爬取商品页面源代码
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4918 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 56ms · UTC 09:53 · PVG 17:53 · LAX 02:53 · JFK 05:53
    ♥ Do have faith in what you're doing.