Skip to content

Commit a428504

Browse files
committed
use https-proxy-agent
1 parent 9850e35 commit a428504

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

package-lock.json

Lines changed: 1 addition & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dotenv": "^8.6.0",
1414
"express": "^4.19.2",
1515
"got": "^11.8.0",
16-
"hpagent": "^1.2.0",
16+
"https-proxy-agent": "^7.0.5",
1717
"metascraper": "^5.14.18",
1818
"metascraper-description": "^5.14.18",
1919
"metascraper-image": "^5.14.18",

src/proxyConfig.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// proxyConfig.js
22
const path = require("path");
3-
const { HttpsProxyAgent, HttpProxyAgent } = require("hpagent");
3+
const { HttpsProxyAgent } = require("https-proxy-agent");
44

55
// Fake user agents array - you can expand this list
66
const FAKE_USER_AGENTS = [
@@ -34,15 +34,15 @@ function getProxyUrl() {
3434

3535
// Main function to get axios config for scraping
3636
async function getScrapingConfig() {
37+
const httpsProxyAgent = new HttpsProxyAgent(getProxyUrl());
3738
return {
3839
headers: {
3940
"User-Agent":
4041
FAKE_USER_AGENTS[Math.floor(Math.random() * FAKE_USER_AGENTS.length)],
4142
},
4243
agent: {
43-
http: new HttpProxyAgent({
44-
http: getProxyUrl(),
45-
}),
44+
https: httpsProxyAgent,
45+
http: httpsProxyAgent,
4646
},
4747
};
4848
}

0 commit comments

Comments
 (0)