Skip to content

Commit 8d014a7

Browse files
committed
Check for Amazon 503
1 parent 80478bf commit 8d014a7

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ There are only two steps to use this program: 1) enter information and 2) launch
103103
3. Consider [donating](https://www.paypal.com/donate?business=3Y9NEYR4TURT8&item_name=Making+software+and+hacking+the+world%21+%E2%99%A5&currency_code=USD) or buying me a [Pizza](https://buymeacoff.ee/PrinceSingh) or [PayPal](https://paypal.me/PrinceSingh25) me :smile:
104104
105105
#### Proxies
106-
If you plan to use low interval rates OR track several items from one store, it is highly recommended that you use proxies such as ones from [Webshare](https://www.webshare.io/) in the format `IP:Port`.<br>\
106+
If you plan to use low interval rates OR track several items from one store, it is highly recommended that you use proxies such as ones from [Webshare](https://www.webshare.io/) in the format `ip:port` for IP-based authentication or `username:password@ip:port`.<br>\
107107
**NOTE:** The following stores do not currently with proxies due to them blocking some connections/headers which results in inconsistent connection: Argos, Best Buy, Costco, and Tesco. Thus we thought it'd be best if we take off proxy support for now until we can do some further research or find an alternative way.
108108
109109

stores/amazon.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ export default async function amazon(url, interval, originalIntervalValue, first
3030

3131
// Setup proxies
3232
if(PROXIES && PROXY_LIST.length > 0) {
33-
if (badProxies.size == PROXY_LIST.length) // If all proxies are used, start over
33+
if (badProxies.size == PROXY_LIST.length) { // If all proxies are used, start over
34+
console.info(moment().format('LTS') + ': Tried all proxies in proxies.txt. Will try them again. Consider getting more proxies.')
3435
badProxies = new Set()
35-
36+
}
3637
do {
3738
proxy = 'http://' + PROXY_LIST[Math.floor(Math.random() * PROXY_LIST.length)];
3839
} while(badProxies.has(proxy))
@@ -51,7 +52,14 @@ export default async function amazon(url, interval, originalIntervalValue, first
5152
// Get Page
5253
res = await axios.get(url, options)
5354
.catch(async function (error) {
54-
writeErrorToFile(store, error);
55+
if (error.response.status == 503) {
56+
console.error(moment().format('LTS') + ': ' + store + ' 503 (service unavailable) Error for ' + url + '. Consider increasing invterval.')
57+
if(PROXIES) {
58+
console.error('Proxy', proxy, 'might be banned from ' + store + '. Adding it to the bad list')
59+
badProxies.add(proxy)
60+
}
61+
}
62+
else writeErrorToFile(store, error);
5563
});
5664

5765

@@ -62,10 +70,12 @@ export default async function amazon(url, interval, originalIntervalValue, first
6270
// If bot Detected
6371
if (html.includes("we just need to make sure you're not a robot")) {
6472
let message = moment().format('LTS') + ': ' + store + ' bot detected. '
65-
if(PROXIES) message += 'For proxy: ' + proxy + '. Consider lowering interval.'
73+
if(PROXIES) {
74+
message += 'For proxy: ' + proxy + '. Consider lowering interval.'
75+
badProxies.add(proxy)
76+
}
6677
else message += 'Consider using proxies or lowering interval.'
6778
console.error(message)
68-
badProxies.add(proxy)
6979
resolve({interval: Math.floor(interval.value + Math.random() * originalIntervalValue), urlOpened: urlOpened})
7080
return
7181
}

0 commit comments

Comments
 (0)