All Projects → moodysalem → java-phantomjs-wrapper

moodysalem / java-phantomjs-wrapper

Licence: MIT License
A Java wrapper around the PhantomJS binaries including a packaged HTML to PDF render script

Programming Languages

java
68154 projects - #9 most used programming language
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to java-phantomjs-wrapper

selenium BDD framework
Behavioural driven development UI automation framework using selenium, cucumber-java, testng, maven, phantomjs
Stars: ✭ 34 (-37.04%)
Mutual labels:  phantomjs
pyderman
Install Selenium-compatible Chrome/Firefox/Opera/PhantomJS/Edge webdrivers automatically.
Stars: ✭ 24 (-55.56%)
Mutual labels:  phantomjs
pyCreeper
一个用来快速提取网页内容的信息采集(爬虫)框架, 实现了对网页的动态加载与控制。
Stars: ✭ 25 (-53.7%)
Mutual labels:  phantomjs
TRA-Ticket-Booker
(已不適用新版臺鐵訂票系統,且不再更新)台灣鐵路訂票應用程式(臺鐵 / 台鐵 / 訂單程票 / 訂來回票),基於 Selenium + PyQt4。
Stars: ✭ 26 (-51.85%)
Mutual labels:  phantomjs
ComicSpider
动漫之家漫画站电脑版原图爬虫
Stars: ✭ 67 (+24.07%)
Mutual labels:  phantomjs
siteshooter
📷 Automate full website screenshots and PDF generation with multiple viewport support.
Stars: ✭ 63 (+16.67%)
Mutual labels:  phantomjs
web-crawler
Python Web Crawler with Selenium and PhantomJS
Stars: ✭ 19 (-64.81%)
Mutual labels:  phantomjs
img-cli
An interactive Command-Line Interface Build in NodeJS for downloading a single or multiple images to disk from URL
Stars: ✭ 15 (-72.22%)
Mutual labels:  phantomjs
www-mechanize-phantomjs
Automate Javascript/Ajax websites with Perl and PhantomJS
Stars: ✭ 19 (-64.81%)
Mutual labels:  phantomjs
kick-off-web-scraping-python-selenium-beautifulsoup
A tutorial-based introduction to web scraping with Python.
Stars: ✭ 18 (-66.67%)
Mutual labels:  phantomjs
MTS
Automation Tools for PHP
Stars: ✭ 111 (+105.56%)
Mutual labels:  phantomjs
jazeee-meteor-spiderable
Fork of Meteor Spiderable with longer timeout, caching, better server handling
Stars: ✭ 33 (-38.89%)
Mutual labels:  phantomjs
crawlkit
A crawler based on Phantom. Allows discovery of dynamic content and supports custom scrapers.
Stars: ✭ 23 (-57.41%)
Mutual labels:  phantomjs
screenshot.py
Taking a screenshot of a webpage.
Stars: ✭ 49 (-9.26%)
Mutual labels:  phantomjs
intransient capybara
A set of improvements to Minitest/Capybara/Poltergeist/PhantomJS test stack that reduces the occurrence of transient failures.
Stars: ✭ 25 (-53.7%)
Mutual labels:  phantomjs
qunit-phantomjs-runner
A PhantomJS-powered headless test runner for QUnit
Stars: ✭ 69 (+27.78%)
Mutual labels:  phantomjs
phantom-lord
Handy API for Headless Chromium
Stars: ✭ 24 (-55.56%)
Mutual labels:  phantomjs
chromate
Automate Headless Chrome.
Stars: ✭ 36 (-33.33%)
Mutual labels:  phantomjs
TqExtension
Test your Drupal 7 (D8 in progress) sites easier with TqExtension for Behat.
Stars: ✭ 13 (-75.93%)
Mutual labels:  phantomjs
Unofficial-Robinhood-Api
Java Wrapper for the Robinhood Investing App/Service
Stars: ✭ 28 (-48.15%)
Mutual labels:  java-wrapper

phantomjs-wrapper

Build Status Maven Central Dependency Status

A Java wrapper around the PhantomJS binaries with additional support for rendering HTML from an InputStream

Install

Use maven to install this module and its dependencies.

<dependency>
  <groupId>com.moodysalem</groupId>
  <artifactId>phantomjs-wrapper</artifactId>
  <version>see pom.xml</version>
</dependency>

3.0 Optional binary dependencies

In 3.0, all the phantom JS binaries are included in separate modules declared as optional dependencies. If you are building a cross platform app, you will need to include all 3. Otherwise, you can include only the optional dependency for the target Operating System.

  <dependency>
    <groupId>com.moodysalem</groupId>
    <artifactId>phantomjs-wrapper-windows-binary</artifactId>
    <version>see pom.xml</version>
  </dependency>

  <dependency>
    <groupId>com.moodysalem</groupId>
    <artifactId>phantomjs-wrapper-linux-binary</artifactId>
    <version>see pom.xml</version>
  </dependency>

  <dependency>
    <groupId>com.moodysalem</groupId>
    <artifactId>phantomjs-wrapper-macosx-binary</artifactId>
    <version>see pom.xml</version>
  </dependency>

JS Execution

The phantomJS script bundled with this wrapper (render.js) to support the public render method described below includes logic for waiting for JS to complete execution before attempting to render the page. A page is considered rendered under any of these conditions:

  • PageRendered is undefined
  • PageRendered is a boolean and equal to true
  • PageRendered is a function and its return value is truthy

Public Interface

/**
 * Another way to call PhantomJS#render using the RenderOptions to specify all the common options
 *
 * @param html    to render
 * @param options for rendering
 * @return same as PhantomJS#render
 * @throws IOException
 * @throws RenderException
 */
public static InputStream render(InputStream html, RenderOptions options) throws IOException, RenderException;

/**
 * Render the html in the input stream with the following properties using a script included with the wrapper
 *
 * @param html         to render
 * @param paperSize    size of the paper (for printed output formats)
 * @param dimensions   dimensions of the viewport
 * @param margin       of the paper
 * @param headerInfo   how the header is generated
 * @param footerInfo   how the footer is generated
 * @param renderFormat the format to render
 * @param jsWait       the maximum amount of time to wait for JS to finish execution in milliseconds
 * @param jsInterval   the interval
 * @return a stream of the rendered output
 * @throws IOException     if any file operations fail
 * @throws RenderException if the render script fails for any reason
 */
public static InputStream render(InputStream html, PaperSize paperSize, ViewportDimensions dimensions,
                                 Margin margin, BannerInfo headerInfo, BannerInfo footerInfo,
                                 RenderFormat renderFormat, Long jsWait, Long jsInterval) throws IOException, RenderException;


/**
 * Execute a script with options and a list of arguments
 *
 * @param script    path of script to execute
 * @param options   options to execute
 * @param arguments list of arguments
 * @return the exit code of the script
 * @throws IOException if cmd execution fails
 */
public static PhantomJSExecutionResponse exec(InputStream script, PhantomJSOptions options, CommandLineArgument... arguments) throws IOException;
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].