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

Python scrapy 怎么做成一个 flask 的接口

  •  
  •   DOUWH · Jun 6, 2019 · 3589 views
    This topic created in 2523 days ago, the information mentioned may be changed or developed.

    ##我想了想,没想出来,

    #比如:

    调用 flask-api 接收参数,参数有 name:张三,age:30,sex:男。
    
    爬虫程序 scrapy 需要拼接这些参数去完成 url 请求,返回 json,或者入库
    
    思考下:
    
    1.flask 怎么传递这些参数给 scrapy,scrapy 又怎么被 flask 所运行。
    2.项目部署该怎么部署,是部署 flask-api 还是部署 scrapy ?
    3.flask 和 scrapy  如何交互
    4.有没有什么好的办法,把 scrapy 爬虫变成一个 api 接口,方便调用的那种
    
    
    各位大佬,尽情的发表意见,小弟在线等
    												
                                                    
                                                    	--来自 python 小白的呐喊
    
    6 replies    2020-03-23 23:16:34 +08:00
    djj510620510
        1
    djj510620510  
       Jun 6, 2019
    用 redis 或者数据库呗
    chengxiao
        2
    chengxiao  
       Jun 6, 2019
    Scrapyd 了解下 剩下的就是调接口
    midasplus
        3
    midasplus  
       Jun 6, 2019
    关键词: scrapyd python-scrapyd-api
    IanPeverell
        5
    IanPeverell  
       Jun 6, 2019
    flask 把 url 存进一个 json 文件,然后用 scrapy.crawl 的 CrawlRunner 调爬虫,爬虫通过读 json 来读 url,爬出来的数据直接入库,flask 通过查增量来获取爬去的新数据。这样的话,只需要起一个 flask,然后爬虫跑在 flask 的进程中,通过 json 文件传 url
    wwb721
        6
    wwb721  
       Mar 23, 2020
    可以看看 scrapyrt
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1084 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 17:27 · PVG 01:27 · LAX 10:27 · JFK 13:27
    ♥ Do have faith in what you're doing.