Hari-Nagarajan / fairgame

Tool to help us buy hard to find items.
GNU General Public License v3.0
2.44k stars 805 forks source link

Proxy rotation #772

Closed hwamil closed 3 years ago

hwamil commented 3 years ago

Tried adding random rotation to the proxies.

Changed the format of proxies.json to just a list to simplify for myself.

In AmazonMonitoringHandler's init, each proxy is placed in a nested dictionary with the idx number as the parent key and the inner dict holding proxy as key and time.time() as value. eg) {31: {user:pw@ip:port : time.time()}}

The function AmazonMonitor.get_new_proxy() is ran in each stock_check function where it uses randint to generate a number between 0 and (number of proxies - 1), which is used to call the dictionary holding the respective proxy address and the last time it was used. All of this is in a while loop that breaks when the condition that the last access time of the time value is greater than 6 seconds.

It's mega clunky and I still don't have a very clear idea how async works and would love some advices to improve or change the design of this. Thanks.