Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ To use **http-request-randomizer** as a library, include it in your requirements
Then you can simply generate a proxied request using a method call:

````python
import logging
import time
from http_request_randomizer.requests.proxy.requestProxy import RequestProxy

if __name__ == '__main__':

start = time.time()
req_proxy = RequestProxy()
req_proxy = RequestProxy(log_level=logging.ERROR)
print("Initialization took: {0} sec".format((time.time() - start)))
print("Size: {0}".format(len(req_proxy.get_proxy_list())))
print("ALL = {0} ".format(list(map(lambda x: x.get_address(), req_proxy.get_proxy_list()))))
Expand All @@ -118,6 +119,9 @@ if __name__ == '__main__':
time.sleep(10)
````

### Changing log levels
The `RequestProxy` constructor accepts an optional parameter of `log_level` that can be used to change the level of logging. By default, this is equal to 0, or NOTSET. The python logging levels are documented [here](https://docs.python.org/3/library/logging.html#logging-levels). You can either use integers or their equivalent constant in the logging module. (e.g. `logging.DEBUG`, `logging.ERROR`, etc)

## Documentation

[http-request-randomizer documentation](https://pgaref.com/HTTP_Request_Randomizer)
Expand Down
4 changes: 2 additions & 2 deletions http_request_randomizer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__author__ = 'pgaref'

__version__ = '1.2.3'
__version__ = '1.3.2'

__title__ = 'http_request_randomizer'
__description__ = 'A package using public proxies to randomise http requests'
Expand All @@ -10,4 +10,4 @@
__email__ = '[email protected]'

__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 ' + __author__
__copyright__ = 'Copyright (c) 2020 ' + __author__
4 changes: 2 additions & 2 deletions http_request_randomizer/requests/proxy/requestProxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@


class RequestProxy:
def __init__(self, web_proxy_list=[], sustain=False, timeout=5, protocol=Protocol.HTTP):
def __init__(self, web_proxy_list=[], sustain=False, timeout=5, protocol=Protocol.HTTP, log_level=0):
self.logger = logging.getLogger()
self.logger.addHandler(handler)
self.logger.setLevel(0)
self.logger.setLevel(log_level)
self.userAgent = UserAgentManager(file=os.path.join(os.path.dirname(__file__), '../data/user_agents.txt'))

#####
Expand Down