免费的代理爬虫插件
import freeProxy from "@ai-lion/lion-free-proxy";
freeProxy 结构
fetch,//用代理get http数据, 等于node-fetch,
createServer({// 创建本地http服务
port: 端口
}),
//获取代理服务列表,需要60秒左右时间才会爬取完, 之前返回本地代理
async getList(): Promise<
{
host: string;
port: string;
type: string;
level: number;
region?: string;
}[]
>,
/**
* 获取随机代理 需要60秒左右时间才会爬取完, 之前返回本地代理
* @returns
*/
async getRandom(): Promise<{
host: string;
port: string;
type: string;
level: number;
region?: string;
}>,
}
fetch 使用
const freeProxy = require("@ai-lion/lion-free-proxy");
freeProxy.createServer(4444);//可以不使用, 创建http服务, 端口4444
freeProxy.getRandom().then(v=>console.info(v));
freeProxy.getList().then(v=>console.info(v));
let res: any = await freeProxy.fetch(url, {
proxy: {
host: proxy.host,
port: port,
type: proxy.type,//协议,http,https
},
});