美文网首页
ubuntu 安装python2/3 的Ghost.py PyS

ubuntu 安装python2/3 的Ghost.py PyS

作者: kelin_liu | 来源:发表于2016-06-07 15:49 被阅读1381次

    先安装 PySide或者qt才能Ghost

    一.需要的依赖

    $sudo apt-get install cmake

    $sudo apt-get install libqt4-dev

    $sudo apt-get install qtmobility-dev

    $sudo apt-get install python2.7-dev

    $sudo apt-get install libphonon-dev

    $pip2 install wheel

    二.安装PySide 

    1.直接 pip

    $ pip3 install PySide

    Collecting PySide

    Using cached PySide-1.2.4.tar.gz

    Complete output from command python setup.py egg_info:

    only these python versions are supported: [(2, 6), (2, 7), (3, 2), (3, 3), (3, 4)]

    可以看出,仅仅支持python 2.6-2.7  3.2-3.4 ,不支持3.5

    $pip install PySide

    2.也可尝试自己编译安装

    wget https://pypi.python.org/packages/source/P/PySide/PySide-1.2.2.tar.gz

    tar -xvzf PySide-1.2.2.tar.gz

    cd PySide-1.2.2

    python setup.py bdist_wheel --qmake=/usr/bin/qmake-qt4

    3.如果安装不成功可尝试

    $sudo apt-get install python-pyside 或者 (sudo apt-get install python3-pyside)

    三.安装Ghost

    直接

    $pip install Ghost.py

    例子:Ghost 0.1.x 和0.2.x区别有点大

    0.1.x

    from ghost import Ghost

    ghost = Ghost()

    page, extra_resources = ghost.open('http://www.baidu.com/')

    if page.http_status==200 and 'accountName' in ghost.content :

            print(age.content)

    0.2.x

    from ghost import Ghost

    ghost = Ghost()

    with ghost.start() as session:

    page, extra_resources = session.open("http://www.baidu.com")

    if page.http_status == 200 and 'accountName' in page.content:

           print(page.content)

    具体区别看文档:http://ghost-py.readthedocs.io/en/latest/

    相关文章

      网友评论

          本文标题:ubuntu 安装python2/3 的Ghost.py PyS

          本文链接:https://www.haomeiwen.com/subject/yewddttx.html