GVKun编程网logo

下载PhantomJS(下载Phantom 加速器)

12

如果您对下载PhantomJS感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于下载PhantomJS的详细内容,我们还将为您解答下载Phantom加速器的相关问题,并且为您提

如果您对下载PhantomJS感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于下载PhantomJS的详细内容,我们还将为您解答下载Phantom 加速器的相关问题,并且为您提供关于16、web爬虫讲解2—PhantomJS虚拟浏览器+selenium模块操作PhantomJS、centos 7安装phantomjs、CentOS NodeJS PhantomJS PhearJS 失败的尝试……、java.lang.IllegalStateException:该驱动程序不可执行:/resources/phantomjs-2.1.1-linux-x86_64/bin/phantomjs的有价值信息。

本文目录一览:

下载PhantomJS(下载Phantom 加速器)

下载PhantomJS(下载Phantom 加速器)

PhantomJS新手?阅读并学习快速入门指南。

视窗

下载phantomjs-2.1.1-windows.zip(17.4 MB)并解压缩(解压缩)内容。

可执行文件phantomjs.exe已准备就绪。

注意:对于此静态构建,二进制文件是自包含的,没有外部依赖项。它将在全新安装的Windows Vista或更高版本上运行。无需安装Qt,WebKit或任何其他库。

Mac OS X.

下载phantomjs-2.1.1-macosx.zip(16.4 MB)并解压缩(解压缩)内容。

注意:对于此静态构建,二进制文件是自包含的,没有外部依赖项。它将在全新安装的OS X 10.7(Lion)或更高版本上运行。无需安装Qt或任何其他库。

Linux 64位

下载phantomjs-2.1.1-linux-x86_64.tar.bz2(22.3 MB)并解压缩内容。

注意:对于此静态构建,二进制文件是自包含的。无需安装Qt,WebKit或任何其他库。但它仍然依赖于Fontconfig(包fontconfiglibfontconfig,取决于分发)。系统必须具有GLIBCXX_3.4.9和GLIBC_2.7。

Linux 32位

下载phantomjs-2.1.1-linux-i686.tar.bz2(23.0 MB)并解压缩内容。

注意:对于此静态构建,二进制文件是自包含的。无需安装Qt,WebKit或任何其他库。但它仍然依赖于Fontconfig(包fontconfiglibfontconfig,取决于分发)。系统必须具有GLIBCXX_3.4.9和GLIBC_2.7。

FreeBSD的

二进制包可通过pkg获得:

$ sudo pkg安装phantomjs

源代码

要获取源代码,请查看官方git存储库:github.com/ariya/phantomjs

要从源代码编译PhantomJS(不推荐,除非绝对必要),请按照构建说明进行操作

校验

要验证下载文件的完整性,请使用以下校验和。

MD5校验和

0396e8249e082f72c1e39d33fc9d8de6 phantomjs-2.1.1-linux-i686.tar.bz2
1c947d57fce2f21ce0b43fe2ed7cd361 phantomjs-2.1.1-linux-x86_64.tar.bz2
b0c038bd139b9ecaad8fd321070c1651 phantomjs-2.1.1-macosx.zip
4104470d43ddf2a195e8869deef0aa69 phantomjs-2.1.1-windows.zip

SHA-256校验和

80e03cfeb22cc4dfe4e73b68ab81c9fdd7c78968cfd5358e6af33960464f15e3 phantomjs-2.1.1-linux-i686.tar.bz2
86dd9a4bf4aee45f1a84c9f61cf1947c1d6dce9b9e8d2a907105da7852460d2f phantomjs-2.1.1-linux-x86_64.tar.bz2
538cf488219ab27e309eafc629e2bcee9976990fe90b1ec334f541779150f8c1 phantomjs-2.1.1-macosx.zip
d9fb05623d6b26d3654d008eab3adafd1f6350433dfd16138c46161f42c7dcc8 phantomjs-2.1.1-windows.zip

承认

下载服务由BitBucket提供,之前由Google Code Project Hosting提供。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

http://phantomjs.org/download.html

16、web爬虫讲解2—PhantomJS虚拟浏览器+selenium模块操作PhantomJS

16、web爬虫讲解2—PhantomJS虚拟浏览器+selenium模块操作PhantomJS

【百度云搜索,搜各种资料:http://www.bdyss.cn】

【搜网盘,搜各种资料:http://www.swpan.cn】

PhantomJS虚拟浏览器

phantomjs 是一个基于js的webkit内核无头浏览器 也就是没有显示界面的浏览器,利用这个软件,可以获取到网址js加载的任何信息,也就是可以获取浏览器异步加载的信息

下载网址:http://phantomjs.org/download...  下载对应系统版本

image

下载后解压PhantomJS文件,将解压文件夹,剪切到python安装文件夹

image

然后将PhantomJS文件夹里的bin文件夹添加系统环境变量

image

cdm 输入命令:PhantomJS  出现以下信息说明安装成功

image

selenium模块是一个python操作PhantomJS软件的一个模块

selenium模块PhantomJS软件

webdriver.PhantomJS()实例化PhantomJS浏览器对象
get(''url'')访问网站
find_element_by_xpath(''xpath表达式'')通过xpath表达式找对应元素
clear()清空输入框里的内容
send_keys(''内容'')将内容写入输入框
click()点击事件
get_screenshot_as_file(''截图保存路径名称'')将网页截图,保存到此目录
page_source获取网页htnl源码
quit()关闭PhantomJS浏览器

#!/usr/bin/env python
# -*- coding:utf8 -*-
from selenium import webdriver  #导入selenium模块来操作PhantomJS
import os
import time
import re

llqdx = webdriver.PhantomJS()  #实例化PhantomJS浏览器对象
llqdx.get("https://www.baidu.com/") #访问网址

# time.sleep(3)   #等待3秒
# llqdx.get_screenshot_as_file(''H:/py/17/img/123.jpg'')  #将网页截图保存到此目录

#模拟用户操作
llqdx.find_element_by_xpath(''//*[@id="kw"]'').clear()                    #通过xpath表达式找到输入框,clear()清空输入框里的内容
llqdx.find_element_by_xpath(''//*[@id="kw"]'').send_keys(''叫卖录音网'')     #通过xpath表达式找到输入框,send_keys()将内容写入输入框
llqdx.find_element_by_xpath(''//*[@id="su"]'').click()                    #通过xpath表达式找到搜索按钮,click()点击事件

time.sleep(3)   #等待3秒
llqdx.get_screenshot_as_file(''H:/py/17/img/123.jpg'')  #将网页截图,保存到此目录

neir = llqdx.page_source   #获取网页内容
print(neir)
llqdx.quit()    #关闭浏览器

pat = "<title>(.*?)</title>"
title = re.compile(pat).findall(neir)  #正则匹配网页标题
print(title)

PhantomJS浏览器伪装,和滚动滚动条加载数据

有些网站是动态加载数据的,需要滚动条滚动加载数据

image

实现代码

DesiredCapabilities 伪装浏览器对象
execute_script()执行js代码

current_url获取当前的url

#!/usr/bin/env python
# -*- coding:utf8 -*-
from selenium import webdriver  #导入selenium模块来操作PhantomJS
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities   #导入浏览器伪装模块
import os
import time
import re

dcap = dict(DesiredCapabilities.PHANTOMJS)
dcap[''phantomjs.page.settings.userAgent''] = (''Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.221 Safari/537.36 SE 2.X MetaSr 1.0'')
print(dcap)
llqdx = webdriver.PhantomJS(desired_capabilities=dcap)  #实例化PhantomJS浏览器对象

llqdx.get("https://www.jd.com/") #访问网址

#模拟用户操作
for j in range(20):
    js3 = ''window.scrollTo(''+str(j*1280)+'',''+str((j+1)*1280)+'')''
    llqdx.execute_script(js3)  #执行js语言滚动滚动条
    time.sleep(1)

llqdx.get_screenshot_as_file(''H:/py/17/img/123.jpg'')  #将网页截图,保存到此目录

url = llqdx.current_url
print(url)

neir = llqdx.page_source   #获取网页内容
print(neir)
llqdx.quit()    #关闭浏览器

pat = "<title>(.*?)</title>"
title = re.compile(pat).findall(neir)  #正则匹配网页标题
print(title)

image

【转载自:http://www.lqkweb.com】

centos 7安装phantomjs

centos 7安装phantomjs

centos 7安装phantomjs

wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
yum install bzip2 # 安装bzip2
tar -jxvf phantomjs-2.1.1-linux-x86_64.tar.bz2
mv phantomjs-2.1.1-linux-x86_64 /usr/local/src/phantomjs
ln -sf /usr/local/src/phantomjs/bin/phantomjs /usr/local/bin/phantomjs
yum install fontconfig freetype2
phantomjs -v # 测试版本号

安装中文字体

yum install bitmap-fonts bitmap-fonts-cjk
yum groupinstall "fonts" -y # 安装字体相关的依赖包
fc-cache # 刷新字体缓存

CentOS NodeJS PhantomJS PhearJS 失败的尝试……

CentOS NodeJS PhantomJS PhearJS 失败的尝试……

Install GCC 4.8+

PhearJS 需要 C11 的支持,而 CentOS 6 目前最新的 gcc 不支持。所以需要自己编译安装 gcc 。这里以 gcc 4.9.4 为例,下载链接以中科大镜像为例:

$ cd ~
$ wget -c http://mirrors.ustc.edu.cn/gnu/gcc/gcc-4.9.4/gcc-4.9.4.tar.bz2
$ tar -jxvf gcc-4.9.4.tar.bz2
$ ./contrib/download_prerequisites
$ cd ..
$ mkdir gcc4.9.4-build
$ cd gcc4.9.4-build
$ ../gcc-4.9.4/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
$ make -j4
$ sudo make install

安装完成后,可以查看 gcc 的版本:

$ gcc --version
gcc (GCC) 4.9.4
copyright (C) 2015 Free Software Foundation,Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or fitness FOR A PARTIculaR PURPOSE.

Install Binutils

在 configure glibc 2.24 的过程中,会提示 as ld 版本过低,所以要首先升级 binutils 。

$ cd ~
$ wget -c http://mirrors.ustc.edu.cn/gnu/binutils/binutils-2.27.tar.gz
$ tar zxvf binutils-2.27.tar.gz
$ mkdir binutils2.27-build && cd binutils2.27-build
$ ../binutils-2.27/configure
$ make -j4
$ make install

Install GLIBC

$ wget -c http://mirrors.ustc.edu.cn/gnu/glibc/glibc-2.24.tar.gz
$ tar zxvf glibc-2.24.tar.gz
$ mkdir glibc2.24-build && cd glibc2.24-build
$ ../glibc-2.24/configure
$ 

configure 的过程提示:

configure: error: 
*** These critical programs are missing or too old: as ld
*** Check the INSTALL file for required versions.

似乎要先把 binutils 也更新了……
然而,在更新了 binutils 之后,又遇到了 linux kernel header files missing or too old! 的问题……感觉还是换服务器比较合适……之前在 Archlinux 上运行 PhearJS 成功过。

checking installed Linux kernel header files... missing or too old!
configure: error: GNU libc requires kernel header files from
Linux 3.2.0 or later to be installed before configuring.
The kernel header files are found usually in /usr/include/asm and
/usr/include/linux; make sure these directories use files from
Linux 3.2.0 or later.  This check uses <linux/version.h>,so
make sure that file was built correctly when installing the kernel header
files.  To use kernel headers not from /usr/include/linux,use the
configure option --with-headers.

Install NodeJS

通过源码编译安装的方法:

$ wget -c https://nodejs.org/dist/v6.9.1/node-v6.9.1.tar.gz
$ tar zxvf node-v6.9.1.tar.gz
$ cd node-v6.9.1
$ ./configure
$ make -j4
$ sudo make install

Install PhantomJS

PhantomJS 的安装比较简单,直接从 PhantomJS 官网下载 binary package ,解压,放入路径中就可以了。本文以 PhantomJS 2.1.1 为例

$ sudo yum install fontconfig
$ cd ~
$ wget -c https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
$ tar -jxvf phantomjs-2.1.1-linux-x86_64.tar.bz2
$ mv phantomjs-2.1.1-linux-x86_64 phantomjs

向 ~/.bashrc 中添加如下的内容:

export PATH=$HOME/phantomjs/bin:$PATH

Install memcached

$ sudo yum install memcached

Install PhearJS

$ cd ~
$ git clone https://github.com/Tomtomgo/phearjs.git
$ cd ~/phearjs
$ npm install

如果觉得 npm 太慢,国内的玩家可以考虑阿里巴巴的淘宝 NPM 镜像: https://npm.taobao.org/
先用以下命令安装 cnpm :

$ sudo npm install -g cnpm --registry=https://registry.npm.taobao.org

然后用 cnpm install 替换 npm install

java.lang.IllegalStateException:该驱动程序不可执行:/resources/phantomjs-2.1.1-linux-x86_64/bin/phantomjs

java.lang.IllegalStateException:该驱动程序不可执行:/resources/phantomjs-2.1.1-linux-x86_64/bin/phantomjs

我正在尝试在Jenkins(Unix)中以无头模式运行Selenium UI测试。我在Unix环境中使用了正确的phantomJS版本。

phantomjs-2.1.1-linux-x86_64/bin/phantomjs

我收到上述错误。有见识吗?如果需要,我将提供更多详细信息。

java.lang.IllegalStateException: The driver is not executable: /resources/phantomjs-2.1.1-linux-x86_64/bin/phantomjs

我们今天的关于下载PhantomJS下载Phantom 加速器的分享已经告一段落,感谢您的关注,如果您想了解更多关于16、web爬虫讲解2—PhantomJS虚拟浏览器+selenium模块操作PhantomJS、centos 7安装phantomjs、CentOS NodeJS PhantomJS PhearJS 失败的尝试……、java.lang.IllegalStateException:该驱动程序不可执行:/resources/phantomjs-2.1.1-linux-x86_64/bin/phantomjs的相关信息,请在本站查询。

本文标签: