Skip to content

onshinpei/spider-by-request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

一个node.js爬虫请求库

自己平常写爬虫时模拟浏览器发请求用到的一个方法,现在单独抽出来作为一个库。 使用request请求库发请求,使用Promise, 支持gbk编码。

如果headers里没有user-agentorigin,那么将使用默认user-agent, origin将根据url设定

安装

  • npm
npm install spider-by-request
  • yarn
yarn add spider-by-request

使用

options 参数是 request的一个扩展,添加参数gbk

const _request = require('spider-by-request');

(async function () {
  const response = await _request({
    uri: 'https://www.baidu.com',
    method: 'GET',
    gbk: false,
  })
  // or
  const response2 = await _request.get('https://www.baidu.com')
})()

About

使用request封装的node.js请求库,支持gbk编码,使用promise

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published