Skip to content

Commit b80932a

Browse files
committed
Add meta
1 parent 7f7f688 commit b80932a

File tree

3 files changed

+51
-25
lines changed

3 files changed

+51
-25
lines changed

README.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# frowser
22

3-
<p align="center">
4-
<br>
5-
<img src="https://i.imgur.com/Mh13XWB.gif" alt="frowser">
6-
<br>
7-
</p>
8-
93
![Last version](https://img.shields.io/github/tag/Kikobeats/frowser.svg?style=flat-square)
104
[![Build Status](https://img.shields.io/travis/Kikobeats/frowser/master.svg?style=flat-square)](https://travis-ci.org/Kikobeats/frowser)
115
[![Coverage Status](https://img.shields.io/coveralls/Kikobeats/frowser.svg?style=flat-square)](https://coveralls.io/github/Kikobeats/frowser)
@@ -14,9 +8,9 @@
148
[![NPM Status](https://img.shields.io/npm/dm/frowser.svg?style=flat-square)](https://www.npmjs.org/package/frowser)
159
[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square)](https://paypal.me/Kikobeats)
1610

17-
**NOTE:** more badges availables in [shields.io](https://shields.io/)
11+
> Simple & Functional Browser API.
1812
19-
> Accessing to browser from the Upside Down
13+
This module is an API simplification over [Chrome Headless API](https://github.com/GoogleChrome/puppeteer) for do common actions, like take an screenshot.
2014

2115
## Install
2216

@@ -35,23 +29,40 @@ frowser('do something')
3529

3630
## API
3731

38-
### frowser(input, [options])
32+
All methods needs a valid `url` as required first argument. The second argument will be `opts` for configure specific method settings.
33+
34+
All methods expose an universal `promise`/`callback` interface: If you provide a function as last argument, then the output of the method will be following `callback` style. Otherwise, it returns an `promise`.
35+
36+
### .html(url, [options], [cb])
37+
38+
It returns the full HTML extracted from the URL.
39+
40+
`opts` provided are passed to [page.goto](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagegotourl-options).
41+
42+
### .pdf(url, [options], [cb])
43+
44+
`opts` provided are passed to [page.goto](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagegotourl-options).
45+
46+
Additionally you can setup the CSS media providing `opts.media` (by default it will be `'screen'`). This value will be passed to [page.emulateMedia](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pageemulatemediamediatype).
47+
48+
### .screenshot(url, [options], [cb])
49+
50+
It takes an screenshot of the URL.
51+
52+
`opts` provided are passed to [page.screenshot](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagescreenshotoptions).
3953

40-
#### input
54+
Additionally, you can setup the `device` providing `opts.device` and a valid [deviceDescriptor](https://github.com/GoogleChrome/puppeteer/blob/master/DeviceDescriptors.js).
4155

42-
*Required*<br>
43-
Type: `string`
56+
It returns an [tmpStream](https://github.com/Kikobeats/create-temp-file2#create-temp-file2), with `path` where the temporal file live and `cleanup`/`cleanupSync` methods for clean the temporal file.
4457

45-
Lorem ipsum.
58+
If you want to customize where tmpStream live, pass [opts.tmpOptions](https://github.com/Kikobeats/create-temp-file2#createtempfileoptions).
4659

47-
#### options
60+
### .text(url, [options], [cb])
4861

49-
##### foo
62+
It returns the text extracted from the URL.
5063

51-
Type: `boolean`<br>
52-
Default: `false`
64+
`opts` provided are passed to [page.goto](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagegotourl-options).
5365

54-
Lorem ipsum.
5566
## License
5667

5768
**frowser** © [Kiko Beats](https://kikobeats.com), Released under the [MIT](https://github.com/Kikobeats/frowser/blob/master/LICENSE.md) License.<br>

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ async function html (url, opts = {}) {
2323
}
2424

2525
async function screenshot (url, opts = {}) {
26-
const { type = 'png', device: deviceDescriptor } = opts
27-
const tempFile = createTempFile({ ext: `.${type}` })
26+
const { tmpOpts, type = 'png', device: deviceDescriptor } = opts
27+
const tempFile = createTempFile(Object.assign({ ext: `.${type}` }, tmpOpts))
2828
const { path } = tempFile
2929

3030
const browser = await puppeteer.launch()
@@ -44,13 +44,14 @@ async function screenshot (url, opts = {}) {
4444

4545
async function pdf (url, opts = {}) {
4646
const tempFile = createTempFile({ ext: `.pdf` })
47+
const { media = 'screen' } = opts
4748
const { path } = tempFile
4849

4950
const browser = await puppeteer.launch()
5051
const page = await browser.newPage()
5152

5253
await page.goto(url, { waitUntil: 'networkidle' })
53-
await page.emulateMedia('screen')
54+
await page.emulateMedia(media)
5455
await page.pdf(Object.assign({ path }, opts))
5556

5657
return Promise.resolve(tempFile)

package.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "frowser",
3-
"description": "Accessing to browser from the Upside Down",
3+
"description": "Simple & Functional Browser API.",
44
"homepage": "https://documentup.com/Kikobeats/frowser",
55
"version": "0.0.0",
66
"main": "index.js",
@@ -16,7 +16,18 @@
1616
"bugs": {
1717
"url": "https://github.com/Kikobeats/frowser/issues"
1818
},
19-
"keywords": [],
19+
"keywords": [
20+
"browser",
21+
"browserless",
22+
"chrome",
23+
"chromeless",
24+
"headless",
25+
"html",
26+
"pdf",
27+
"puppeteer",
28+
"screenshot",
29+
"text"
30+
],
2031
"dependencies": {
2132
"create-temp-file2": "~2.0.0",
2233
"puppeteer": "~0.10.2"
@@ -36,6 +47,9 @@
3647
"engines": {
3748
"node": ">= 6"
3849
},
50+
"files": [
51+
"index.js"
52+
],
3953
"scripts": {
4054
"clean": "rm -rf node_modules",
4155
"coveralls": "nyc report --reporter=text-lcov | coveralls",
@@ -49,8 +63,8 @@
4963
"license": "MIT",
5064
"lint-staged": {
5165
"*.js": [
52-
"prettier-standard",
53-
"git add"
66+
"git add",
67+
"prettier-standard"
5468
]
5569
},
5670
"standard": {

0 commit comments

Comments
 (0)