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

python 和 php 通讯用什么办法比较好,有没有成熟的框架

  •  
  •   letitbesqzr · Oct 10, 2013 · 5199 views
    This topic created in 4595 days ago, the information mentioned may be changed or developed.
    考虑过直接用php来执行系统命令 调用python ... 也考虑过用socket 的办法..但socket的办法总处理不好线程之类的... 大家都用什么办法.比如 一个爬虫程序...web是php写的..通过游览器传递要爬的页面.后端用python来爬后 返回数据给php 在网页端显示出来.. 有没有能实现这种功能的成熟框架
    8 replies    1970-01-01 08:00:00 +08:00
    pathletboy
        1
    pathletboy  
       Oct 10, 2013
    如果处理不好socket线程,那就php录入数据后放数据库,python定期从数据库取出(python自己访问数据库或者通过php以http方式)开始任务,爬完写回数据库,php再从数据库里取出显示出来。
    cctvsmg
        2
    cctvsmg  
       Oct 10, 2013   ❤️ 1
    redis memcache mysql 都行
    反正就是把一个要抓取的网址的json数组存了数据库里面去

    python抓到的东西也这么存
    xingzhi
        3
    xingzhi  
       Oct 10, 2013   ❤️ 1
    http://redis.io/topics/pubsub
    消息订阅就好了, php 是发布方,python 作为订阅方,一拿到任务就开始爬。
    andyhuax
        4
    andyhuax  
       Oct 10, 2013
    用RQ啊
    lupino
        5
    lupino  
       Oct 10, 2013
    o(∩∩)o...哈哈, 可以考率 用 [gearman](http://gearman.org)
    clino
        6
    clino  
       Oct 10, 2013
    感觉用redis比较合适,数据格式可以用json之类的
    ipconfiger
        7
    ipconfiger  
       Oct 10, 2013
    Redis的订阅发布就好啦,或者python端blpop也行,php端rpush到队列里就行了
    figol
        8
    figol  
       Oct 16, 2013
    额。不同语言通信 web service 这个比较OK
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1033 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 18:27 · PVG 02:27 · LAX 11:27 · JFK 14:27
    ♥ Do have faith in what you're doing.