phantomjs

How to use ES6 with PhantomJS

时间秒杀一切 提交于 2019-12-28 13:42:33
问题 Is there a way to use ES6 and modules with PhantomJS? I can transpile each file from ES6 to ES5 using Babel, but it's awkward to maintain parallel trees (one in ES6 and another in ES5) and write the imports to require the ES5 modules. I'm looking for a cleaner solution. I can remove all import and export code, concatenate the modules together, transpile the result into a single file, then run in through PhantomJS, but I'd prefer to use imports and exports if possible. I tried using Browserify

Getting screenshot using PhantomJS in C# [duplicate]

浪尽此生 提交于 2019-12-28 13:35:13
问题 This question already has answers here : How to take screenshot with Selenium WebDriver (43 answers) Closed 5 years ago . I have added PhantomJS and Selenium to my C# console app and i want to take a screen shot of the browser when it gets to a specific element. The reason is because for some reason when i use the ChromeDriver it works fine, but when i use PhantomJS it fails on a few elements. I guess i need an introduction on how to take a screenshot in C# using phantomjs. I have looked

Running Phantomjs from javascript, JSP or Java

大憨熊 提交于 2019-12-28 12:42:26
问题 Hi i am new to phantomjs, I have generated HTML to PDF by using command. But i want to generate PDF by clicking a button on the page. and call phantomjs by some way to generate my given URL to pdf. You can also suggest some api that generate generate PDF as HTML with charts and images and can easily integrated with JSP and Servlet. 回答1: I'm assuming that what you want to do is to run the phantomjs executable from within Java code. You'll need to first know the full path of the command you

casperjs download csv file

自作多情 提交于 2019-12-28 05:29:26
问题 I am trying to download a csv file(advert report) from a site using the below code. The issue is, it will download the HTML page and not the csv file. I cannot give you the URL as it is behind the login, but it is similar case when you download Firefox from the below URL http://www.mozilla.org/en-US/firefox/new/ It is a GET request and when I do inspect element Network Tab the get request gets Cancelled. I am new to Casper and don't know how to handle such requests. Any help would be

Using Selenium with Python and PhantomJS to download file to filesystem

帅比萌擦擦* 提交于 2019-12-28 05:21:26
问题 I've been grappling with using PhantomJS/Selenium/python-selenium to download a file to the filesystem. I'm able to easily navigate through the DOM and click, hover etc. Downloading a file is, however, proving to be quite troublesome. I've tried a headless approach with Firefox and pyvirtualdisplay but that wasn't working well either and was unbelievably slow. I know That CasperJS allows for file downloads. Does anyone know how to integrate CasperJS with Python or how to utilize PhantomJS to

how to wait for element visibility in phantomjs

前提是你 提交于 2019-12-27 20:10:24
问题 Users click this link: <span onclick="slow_function_that_fills_the_panel(); $('#panel').show();"> Now I'm simulating the click in phantomjs: page.evaluate( function() { $("#panel").click(); } ); console.log('SUCCESS'); phantom.exit(); Phantom exits before the slow function ends its execution and the DIV becomes visible. How can I implement waiting? 回答1: Heres a spin of Cybermaxs's answer: function waitFor ($config) { $config._start = $config._start || new Date(); if ($config.timeout && new

PhantomJS命令行选项

◇◆丶佛笑我妖孽 提交于 2019-12-26 00:44:09
支持命令行选项有: --help 或 -h 列出所有可能的命令行选项。 立即停止,不会运行一个脚本作为参数传递。 --version 或 -v 打印的版本PhantomJS。 立即停止,不会运行一个脚本作为参数传递。 --debug=[true|false] 输出额外的警告和调试信息,默认 false 。 也接受: [yes|no] 。 --config 指定json格式的配置文件(见下文)。 --cookies-file=/path/to/cookies.txt 指定文件名存储持久化cookie。 --disk-cache=[true|false] 使磁盘缓存(在桌面服务缓存存储位置,默认 false )。 也接受: [yes|no] 。 --disk-cache-path 指定磁盘高速缓存的位置。 --ignore-ssl-errors=[true|false] 忽略了SSL错误,如过期或自签名证书(默认是错误 false )。 也接受: [yes|no] 。 --load-images=[true|false] (默认加载所有内联图像 true )。 也接受: [yes|no] 。 --local-storage-path=/some/path 路径保存LocalStorage内容和WebSQL内容。 --local-storage-quota=number 允许最大尺寸数据

盘点selenium phantomJS使用的坑

99封情书 提交于 2019-12-25 22:23:12
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> selenium是python的一个第三方自动化测试库,虽然是测试库,却也非常适合用来写爬虫,而phantomJS是其子包webdriver下面的一个浏览器。phantomJS本身是一个无头浏览器(headless browser),也称无界面浏览器。可以在通过官网下载运行phantomjs.exe,简单几行代码也能访问网页,爬取数据。但本文主要讨论通过python的selenium库使用phantomJS。除了phantomJS浏览器,webdriver还整合了Chrome、Firefox、IE等浏览器,并提供了操作这些浏览器的接口。 由于phantomJS是无界面浏览器,不需要界面的同时占用的内存也相对较小,更适用于大规模多进程爬数据(试想,如果开几十个Chrome进程爬数据,那真是内存噩梦!)。本文主要讨论使用selenium phantomJS过程中遇到的bug,而不是selenium phantomJS使用教程,有需要了解selenium基本用法的同学,请移步官方文档。 1. 查看phantomJS文档 phantomJS是selenium子包webdriver下面多个浏览器中的一个,而selenium包对不同的浏览器都提供了统一的接口,所以直接查看selenium的官方文档即可,也有对应的中文文档

Selenium+PhantomJS爬虫之路

故事扮演 提交于 2019-12-25 22:04:33
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 爬虫三剑客:python--手 selenium--剑柄 phantomjs--剑尖 Selenium 一、简介 Selenium是一个自动化测试工具,支持包括Chrome,Firefox,Safari,PhantomJs等一些浏览器。如果用于爬虫中,我们主要用来解决一些JavaScript渲染的问题。 我们在使用Requests库去请求一些网页的时候,比如 163music,我们获得的响应数据呢,并不全是我们在浏览器中看到的信息。他可能是通过js渲染出来的。那么,我们如果使用Selenium库,就不会再去关心如何去解决这种问题了。 因为我们的浏览器,比如PhantomJs,他就是一个无界面的浏览器,他用来渲染解析js,而Selenium库就负责给浏览器发送一些命令,模拟一些比如下拉,拖拽,翻页,输入表单等动作。这样他们两个结合,对于那些 JS 的渲染问题是不是完美解决了。 注意: 虽然Selenium库加上PhantomJs很好用,但是他毕竟是驱动一个浏览器,然后获取数据。所以在我们使用中,会发现他并没有我们使用一些解析库速度快。这其实就是他的弊端,所以我还是建议大家,不到实在找不到解决办法的时候,不去使用他们。 二、安装 Windows 第一种方法是:下载源码安装,下载地址( https://pypi

How to set the PhantomJSOptions in Selenium for proxy-type?

落花浮王杯 提交于 2019-12-25 18:41:49
问题 Using Selenium and the web driver to drive phantomjs as part of a web scraping project. From the "Known Issues" for Windows at PhantomJS, it is suggested that the proxy-type be set to "none" to speed up network performance. I tried the following: PhantomJSOptions options = new PhantomJSOptions(); options.AddAdditionalCapability("proxy", "{proxyType:none}"); However, this sets proxy to a string and I think I need a json object. Can someone show me how to do this correctly? 回答1: Use the driver