Coder Social home page Coder Social logo

makarasty / socks-scraper Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 38 KB

🔆 Library for Node.js for proxy collection and validation

License: Apache License 2.0

JavaScript 100.00%
jsdoc nodejs nodejs-modules proxies proxies-checker proxies-list proxies-scraper proxy proxy-checker proxy-scraper

socks-scraper's Introduction

Proxy Scraper

Library for Node.js for proxy collection and validation

Install

  • npm i socks-scraper

OS Dependencies

  • Node.js

Lib Dependencies

  • undici
  • socks

JSDoc

/**
 * like { address, host, port, latency }
 * @typedef {Object} SocksScraper.IDefaultProxy
 * @property {string} address
 * @property {string} host
 * @property {number} port
 * @property {number} latency
 */

Usage example

const SocksScraper = require('socks-scraper');

// Initialize the scraper with a list of raw sites
const socksScraper = new SocksScraper([
	"https://raw.githubusercontent.com/casals-ar/proxy-list/main/socks5",
	"https://raw.githubusercontent.com/casals-ar/proxy-list/main/socks4",
	"https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/socks4.txt",
	"https://raw.githubusercontent.com/ShiftyTR/Proxy-List/master/socks4.txt",
	"https://shieldcommunity.net/sockets.txt"
])

// Add one more site to the list of sites on which free proxies are placed
socksScraper.addSites(["https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/socks4.txt"])

// Timeout for checking the proxy in ms
const timeout = 6000

console.log('Updating unchecked proxies...');
// Gets proxies from all sites, VERY IMPORTANT: it must be called before the getWorkedSocksProxies()
await socksScraper.updateUncheckedProxies()

console.log('Done updating unchecked proxies!');

// Get a list of proxies from all sites, check if they work and return the best ones
const wsp4 = await socksScraper.getWorkedSocksProxies(4, timeout)
// Sort the list by latency and take the fastest proxy
const bestWSP4 = SocksScraper.filterByLatency(wsp4)[0]

console.log(`The best socks4 proxy is ${bestWSP4.host}:${bestWSP4.port} with latency ${bestWSP4.latency}ms`)

const wsp5 = await socksScraper.getWorkedSocksProxies(5, timeout, 1, 20000)
const bestWSP5 = SocksScraper.filterByLatency(wsp5)[0]

console.log(`The best socks5 proxy is ${bestWSP5.host}:${bestWSP5.port} with latency ${bestWSP5.latency}ms`)

// Check my socks5 proxy to see if it works at all
const mySocks5Proxy = await SocksScraper.checkSocksProxy(5, '94.131.14.66:1080', 4000)
const isAlive = Boolean(mySocks5Proxy)

console.log(`My socks5 proxy is ${isAlive ? 'alive' : 'dead'}`)
console.log(mySocks5Proxy)
My socks5 proxy is alive!
{
	address: '3.122.84.99:3128',
	host: '3.122.84.99',
	port: 3128,
	latency: 32
}

socks-scraper's People

Contributors

makarasty avatar

Stargazers

 avatar  avatar

Watchers

 avatar

socks-scraper's Issues

poor website

TypeError: Cannot read properties of undefined (reading 'split')
at SocksScraper.checkSocksProxy (E:\Главная папка\Bot\ProxyScraper\node_modules\socks-scraper\index.js:115:35)
at E:\Главная папка\Bot\ProxyScraper\node_modules\socks-scraper\index.js:147:23
at Array.map ()
at SocksScraper.getWorkedSocksProxies (E:\Главная папка\Bot\ProxyScraper\node_modules\socks-scraper\index.js:146:5)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Promise.all (index 1)
at async main (E:\Главная папка\Bot\ProxyScraper\index.js:66:23)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.