Skip to content

Commit

Permalink
use https-proxy-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
anish-work committed Nov 13, 2024
1 parent 9850e35 commit a428504
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
11 changes: 1 addition & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dotenv": "^8.6.0",
"express": "^4.19.2",
"got": "^11.8.0",
"hpagent": "^1.2.0",
"https-proxy-agent": "^7.0.5",
"metascraper": "^5.14.18",
"metascraper-description": "^5.14.18",
"metascraper-image": "^5.14.18",
Expand Down
8 changes: 4 additions & 4 deletions src/proxyConfig.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// proxyConfig.js
const path = require("path");
const { HttpsProxyAgent, HttpProxyAgent } = require("hpagent");
const { HttpsProxyAgent } = require("https-proxy-agent");

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

// Main function to get axios config for scraping
async function getScrapingConfig() {
const httpsProxyAgent = new HttpsProxyAgent(getProxyUrl());
return {
headers: {
"User-Agent":
FAKE_USER_AGENTS[Math.floor(Math.random() * FAKE_USER_AGENTS.length)],
},
agent: {
http: new HttpProxyAgent({
http: getProxyUrl(),
}),
https: httpsProxyAgent,
http: httpsProxyAgent,
},
};
}
Expand Down

0 comments on commit a428504

Please sign in to comment.