@crawly/browser
v1.0.2
Published
lib to encapsulate browser data
Downloads
11
Keywords
Readme
grasshopper-lib-browser
Instalação
npm i @crawly/browser
Usando
import { Browser } from '@crawly/browser';
let browser = new Browser();
let header = browser.getHeaders();
Exemplo de retorno da função getHeaders
:
{
Pragma: 'no-cache',
Connection: 'keep-alive',
'Accept-Encoding': 'gzip, deflate, br',
'Content-Type': 'application/json; charset=UTF-8',
'Cache-Control': 'no-cache',
'Upgrade-Insecure-Requests': 1,
'X-Requested-With': 'XMLHttpRequest',
Accept:'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7',
Referer: 'https://www.google.com',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0'
}
Para gerar novos headers utilize a função setHeaders
:
import { Browser } from '@crawly/browser';
let browser = new Browser();
browser.setHeaders();
API
setHeaders(): void;
getHeaders(): IHeader;
mergeHeaders(headers: IHeader, value: IHeader): IHeader;
getRandomAccept(): string;
getRandomAcceptLanguage(): string;
getRandomReferer(): string;
getRandomUserAgent(): string;
Build
npm run build
Lint
npm run tslint
Testes
npm test
Coverage
npm run coverage