socks-scraper
Advanced tools
Comparing version 1.0.0 to 1.0.1
42
index.js
@@ -96,10 +96,14 @@ const { SocksClient } = require('socks'); | ||
* @param {string} url | ||
* @returns {Promise<string[]>} | ||
* @returns {Promise<string[] | []>} | ||
*/ | ||
async getProxiesFromRawSite(url) { | ||
const response = await request(url, { method: "GET", headers: this.headers }) | ||
const responseText = await response.body.text() | ||
try { | ||
const response = await request(url, { method: "GET", headers: this.headers }) | ||
const responseText = await response.body.text() | ||
const proxyList = responseText.split('\n').filter((x) => x.match(ipPortRegex)) | ||
return proxyList | ||
const proxyList = responseText.split('\n').filter((x) => x.match(ipPortRegex)) | ||
return proxyList | ||
} catch (error) { | ||
return [] | ||
} | ||
} | ||
@@ -116,16 +120,20 @@ | ||
async checkSocksProxy(type, address, timeout = 5000) { | ||
const [host, portStr] = address.split(':'); | ||
const port = Number(portStr); | ||
try { | ||
const [host, portStr] = address.split(':'); | ||
const port = Number(portStr); | ||
const startTime = performance.now(); | ||
const result = await SocksClient.createConnection({ | ||
timeout, | ||
command: 'connect', | ||
destination: { host: this.checkURL, port: this.checkURLPort }, | ||
proxy: { host, port, type } | ||
}) | ||
.then(() => ({ address, host, port, latency: Math.round(performance.now() - startTime) })) | ||
.catch(() => null); | ||
const startTime = performance.now(); | ||
const result = await SocksClient.createConnection({ | ||
timeout, | ||
command: 'connect', | ||
destination: { host: this.checkURL, port: this.checkURLPort }, | ||
proxy: { host, port, type } | ||
}) | ||
.then(() => ({ address, host, port, latency: Math.round(performance.now() - startTime) })) | ||
.catch(() => null); | ||
return result; | ||
return result; | ||
} catch (error) { | ||
return null | ||
} | ||
} | ||
@@ -132,0 +140,0 @@ |
@@ -7,3 +7,3 @@ { | ||
"name": "socks-scraper", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Uses your references to obtain and verify proxies ", | ||
@@ -10,0 +10,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18273
140