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

scrapy 如何才能请求 word 文件源链接后返回的内容保存到 mysql 数据库?

  •  
  •   NLL · Aug 20, 2017 · 2474 views
    This topic created in 3330 days ago, the information mentioned may be changed or developed.

    scrapy 如何才能请求 word 文件源链接后返回的内容保存到数据库? 这么描述不知道对不对,就是想通过 scrapy 来把网上的 word 文档直接保存到 mysql 数据库中。 我查询网上说的是可以以二进制形式保存进 mysql 数据库中。

    由于爬取的网站需要登录,所以用的 Requset 传递 cookie,但麻烦的是,返回的 response 的 type 是'scrapy.http.response.html.HtmlResponse',并没有 content 属性。那么问题是,返回的 response 如何转换成二进制?

    同时,也想问一下,Spider 中模拟登录后一直传递的 cookiejar 怎么才能转换成 request 可以用的 cookie 格式?还是说可以直接拿来用??这个解决了的话,那么我是不是在最后请求 word 文件源链接的时候,用 request 就可以返回 response.content 了??

    说的有点乱。。。抱歉

    3 replies  •  2017-08-21 08:43:59 +08:00
    NLL
        1
    NLL  
    OP
       Aug 20, 2017
    求大佬解惑啊
    BooksE
        2
    BooksE  
       Aug 20, 2017
    好奇特的需求
    NLL
        3
    NLL  
    OP
       Aug 21, 2017 via iPhone
    @BooksE 项目要求的…已经解决了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2476 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 14:03 · PVG 22:03 · LAX 07:03 · JFK 10:03
    ♥ Do have faith in what you're doing.