ubuntu安装phantomjs

 
ubuntu安装phantomjs
 
下载地址
解压
$ tar -xvf phantomjs-2.1.1-linux-x86_64.tar.bz2
$ sudo mv phantomjs-2.1.1-linux-x86_64 /usr/local/phantomjs
命令连接到/usr/bin目录下
$ ln -s /usr/local/share/phantomjs/bin/phantomjs /usr/bin/phantomjs
 
pip3 install selenium==3.8.0
phantomjs用2.1.1的
 
>>> from selenium import webdriver
>>> browser=webdriver.PhantomJS()     #JS要用大写
>>> browser.get("https://www.baidu.com")
>>> print(browser.current_url)
>>> browser.refresh()  #刷新页面
 
 
 
dockerfile
FROM ubuntu
COPY phantomjs-2.1.1 /usr/local/phantomjs
RUN apt-get update && \
    apt-get install -y python3 && \
    apt-get install -y python3-pip && \
    apt install -y libfontconfig && \
    pip3 install selenium==3.8.0 && \
    ln -s /usr/local/phantomjs/bin/phantomjs /usr/bin/phantomjs

 

posted @ 2020-11-25 09:37  坚强的小蚂蚁  阅读(551)  评论(0编辑  收藏  举报