phantomjs

python利用selenium+phantomJS爬淘宝

匿名 (未验证) 提交于 2019-12-02 22:54:36
time.sleep(2) 然后你去刚刚的文件看看是不是有一张图片显示出来,对的,就是如下图所示,价格出来了有没有.但是有个问题就是,感觉除了上部分能加载完,其余部分是空白的. ![image.png](https://upload-images.jianshu.io/upload_images/4151356-f67a28728bb08884.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 所以进行第四步,模拟滚动. 4. 模拟滚动,代码如下,我写成函数来调用了,方便调用,还有,一下为完整的代码: ```python #导入selenium from selenium import webdriver from selenium.webdriver.common.keys import Keys import time driver = webdriver.PhantomJS(executable_path="phantomjs/bin/phantomjs.exe") #然后填入刚刚的淘宝url driver.get("https://s.taobao.com/search?q=dp%E8%BD%AChdmi&imgfile=&commend=all&ssid=s5-e&search_type=item

selenium.common.exceptions.WebDriverException: Message: 'Can not connect to GhostDriver'

♀尐吖头ヾ 提交于 2019-12-02 22:44:34
I'm trying to run PhantomJS from within selenium.webdriver on a Centos server. PhantomJS is in the path and is running properly from terminal. However in the script it appears to be launched, but afterwards cannot be reached on the specified port (I tried 2 different opened ports from my provider 29842 and 60099, they both are not working and neither launching it without a specified port). The error happens here in selenium.webdriver.common.utils : try: socket_ = socket.socket(socket.AF_INET, socket.SOCK_STREAM) socket_.settimeout(1) socket_.connect(("localhost", port)) socket_.close() return

elasticsearch5.3安装插件head

烂漫一生 提交于 2019-12-02 22:19:33
1、下载并配置nodejs cd /usr/local/src/ wget https://nodejs.org/dist/v6.9.5/node-v6.9.5-linux-x64.tar.xz && xz -d node-v6.9.5-linux-x64.tar.xz tar -xvf node-v6.9.5-linux-x64.tar -C /usr/local/ ln -s /usr/local/node-v6.9.5-linux-x64/bin/node /usr/bin/node ln -s /usr/local/node-v6.9.5-linux-x64/bin/npm /usr/bin/npm node -v && npm -v 2、安装head插件 npm install -g grunt-cli ln -s /usr/local/node-v6.9.5-linux-x64/lib/node_modules/grunt-cli/bin/grunt /usr/bin/grunt 3、下载并配置head cd /var/lib/elasticsearch git clone git://github.com/mobz/elasticsearch-head.git chown -R elasticsearch:elasticsearch elasticsearch

How to update phantomjs 1.9.8 to phantomjs 2.1.1 on ubuntu?

本秂侑毒 提交于 2019-12-02 22:11:17
I cant reinstall phantomjs 1.9.8 to 2.1.1 version on my ubuntu 16.04 Please help. 1.9.8 give me an errors when I write a spin functions, in documentation see that this ploblem I can solve with reinstalation. I just installed phantomjs 2.1.1 in ubuntu 16.04 with the following steps, which I found after a bit of googling : sudo apt-get install nodejs sudo apt-get install nodejs-legacy sudo apt-get install npm sudo npm -g install phantomjs-prebuilt So, jmunsch's answer works for me, but just to provide a clear and minimal recipe: export PHANTOM_JS_VERSION=2.1.1 sudo apt-get install libfontconfig

Linux/CentOS环境下如何安装和配置PhantomJS工作环境

匿名 (未验证) 提交于 2019-12-02 21:59:42
1. 安装步骤 1.1 在服务器上新建想要下载和安装的目录: 1.2 下载PhantomJS安装包 [plain] view plain copy 执行结果如下图: 1.3 解压工具包 [python] view plain copy 2.1 . 1 执行时报如下错误: tar (child): cannot run bzip2: No such file or directory 出现上述错误,请安装bzip2 执行指令: [python] view plain copy 再次执行解压指令: 成功完成解压。 将可执行文件放入系统路径 [python] view plain copy 2.1 . 1 安装依赖――fontconfig和freetype: [python] view plain copy [python] view plain copy 在终端下测试Phantomjs   注意系统目录为/usr/bin/ 至此成功 文章来源: Linux/CentOS环境下如何安装和配置PhantomJS工作环境

PhantomJS抓取中文文档乱码

匿名 (未验证) 提交于 2019-12-02 21:53:52
使用PhantomJs抓取百度标题乱码 var url="http://www.baidu.com" var page=require('webpage').create() page.open(url,function (status) { var title=page.evaluate(function () { return document.title; }) console.log('Page title is ',title) phantom.exit() }) 结果: 解决方法: phantomjs --output-encoding=gb2312 getHtmlTitle.js 来源:博客园 作者: feiquan 链接:https://www.cnblogs.com/feiquan/p/11416310.html

Java实现网页截屏功能(基于phantomJs)

匿名 (未验证) 提交于 2019-12-02 21:53:52
Robot 利用JNI,调用第三方C/C++组件 DJNativeSwing组件 利用html2canvas 利用html2image phantomJs http://phantomjs.org/download.html ,也可以通过(只有windows版本):https://pan.baidu.com/s/1EVX1RPX7gY0rGvEI6OHcwg 密码:brb4 下载;解压后可以看到 var page = require(‘webpage‘ ).create(), system = require(‘system‘ ), address, output, size; if (system.args.length < 3 || system.args.length > 5 ) { phantom.exit( 1 ); } else { address = system.args[1]; // 传入url地址 output = system.args[2]; // 输出图片的地址 page.viewportSize = { width: 800, height: 1800 }; // 自定义定义宽高 if (system.args.length > 3 && system.args[2].substr(-4) === ".pdf" ) { size = system

not able to write the qunit test results to output xml using build.xml

谁说我不能喝 提交于 2019-12-02 21:44:23
问题 I am using build.xml with phantom.js to execute the qunit testcases,test are passing but the results are not getting written to output xml file.qunit.done function of qunit.runner.js gives Cannot write junit results file error in QUnit.done function. any one has any idea/suggestion thanks in advance 来源: https://stackoverflow.com/questions/23238119/not-able-to-write-the-qunit-test-results-to-output-xml-using-build-xml

PhantomJS change webpage content before evaluating

北战南征 提交于 2019-12-02 21:19:34
I'd like to either remove an HTML element or simply remove first N characters of a webpage before evaluating/rendering it. Is there any way to do that? It depends on multiple scenarios. I will only outline the steps for each combination of the answers to the following questions. Is the piece of JS called onload ( ol ) or is the script block immediately evaluated ( ie )? Is it an inline script ( is ) or is the script loaded separately (src attribute) ( ls )? Does the script block also contain some code that should not be removed ( nr ) or can it be removed completely ( rc )? 1. Script is loaded

PhantomJS/CasperJS site login, cookies are not accepted by PhantomJS

大憨熊 提交于 2019-12-02 21:02:57
I recently tried to login into a webiste that forces me to accept cookies. I'm using phantomJs and casperJs. I wrote a little script that should handle the login, but it redirects me to a site that tells me I have to accept cookies. Email and password are just placeholders. The site I want to login is https://de.buyvip.com/ . But I need to click the button Anmelden mit Amazon so I can login with my amazon account. The other login form does not work. (That leads to this long url, I just copied it from my browser) Can someone help me? Here is the script: var casper = require("casper").create()