# weare-phantomjs-html

> Render URLs and return their HTML content.

Latest version **0.4.4** (published 2018-11-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install weare-phantomjs-html
pnpm add weare-phantomjs-html
yarn add weare-phantomjs-html
bun add weare-phantomjs-html
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.4 |
| Published | 2018-11-05 |
| First published | 2018-11-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | William McMurray |
| Maintainers | smcyr |
| Keywords | node, phantomjs, html, render, seo, one-pager, SPA |

## Links

- npm: https://www.npmjs.com/package/weare-phantomjs-html
- npm.io page: https://npm.io/package/weare-phantomjs-html

## Dependencies (2)

- [merge](https://npm.io/package/merge.md) ^1.2.0
- [phantomjs-prebuilt](https://npm.io/package/phantomjs-prebuilt.md) ^2.1.7

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.4.4 (latest) — 2018-11-05

## README

# weare-phantomjs-html

This module enables **retrieval of the HTML output of URLs** via an easy to use middleware.

## Install

`npm install --save weare-phantomjs-html`

## How to use

### 1. Use the ExpressJS middleware

This middleware need to be used before any routing is done. It will detect if the current request 
is made from a crawler using the `User-Agent` header and `_escaped_fragment_` URL query param. 
If a crawler is detected, it will return a PhantomJS rendering of the page that suitable for those crawlers.
```js
var phantomjsHtml = require('weare-phantomjs-html');

// output PhantomJS render of pages if the request is made by a crawler
app.use(phantomjsHtml.middleware());
```

### 2. Delaying the PhantomJS output

In single pages apps, there is often JavaScript executed after the page has loaded to load or display data. 
You can instruct the rendering script to wait until your app is ready like so :  

In the `<head>` section of your HTML pages :

```html
<script type="text/javascript">
  window.phantomjsHtmlReady = false;
</script>
```

And when the page is ready to be rendered, just set `phantomjsHtmlReady` to `true`.

```js
window.phantomjsHtmlReady = true;
```

## Source

Original module: [phantomjs-html](https://github.com/wmcmurray/phantomjs-html)

---
_Source: https://npm.io/package/weare-phantomjs-html · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
