Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

socks-scraper

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

socks-scraper

Uses your references to obtain and verify proxies

  • 1.1.0-h
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
0
Weekly downloads
 
Created
Source

Proxy Scraper

Library for Node.js for proxy collection and validation

Install

  • npm i socks-scraper

OS Dependencies

  • Node.js

Lib Dependencies

  • needle
  • proxy-agent

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://api.proxyscrape.com/?request=displayproxies&status=alive",
	"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://api.proxyscrape.com/?request=displayproxies&status=alive&proxytype=socks4',
	'https://api.proxyscrape.com/?request=displayproxies&status=alive&proxytype=socks5',
	'https://openproxylist.xyz/socks4.txt',
	'https://openproxylist.xyz/socks5.txt',
	'https://raw.githubusercontent.com/sunny9577/proxy-scraper/master/proxies.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! (${socksScraper.unCheckedProxies.size})`);

// Get a list of proxies from all sites, check if they work and return the best ones
const wsp4 = await socksScraper.getWorkedSocksProxies('socks4', 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 (${wsp4.length})`)

const wsp5 = await socksScraper.getWorkedSocksProxies('socks5', timeout)
const bestWSP5 = SocksScraper.filterByLatency(wsp5)[0]

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

/* only if you have VERY good internet...

const http = await socksScraper.getWorkedSocksProxies('http', timeout)
const bestHttp = SocksScraper.filterByLatency(http)[0]

console.log(`The best http proxy is ${bestHttp.host}:${bestHttp.port} with latency ${bestHttp.latency}ms`)
*/

//  Check my socks5 proxy to see if it works at all
const mySocks4Proxy = await SocksScraper.isAliveProxy('socks4', '3.10.93.50:80', 10000)
const isAlive = Boolean(mySocks4Proxy)

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

Keywords

FAQs

Package last updated on 14 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc