1
- HTTP Request Randomizer |Build Status | |Coverage Status | |Dependency Status | |PyPI version |
2
- ===========================================================================================
1
+ HTTP Request Randomizer |Build Status | |codecov | |Requirements Status | |PyPI version |
2
+ =====================================================================================
3
3
4
4
`Vietnamese version <README-vi.md >`__
5
5
6
- A convenient way to implement HTTP requests is using Pythons'
6
+ A convenient way to implement HTTP requests is using Pythons’
7
7
**requests ** library. One of requests’ most popular features is simple
8
8
proxying support. HTTP as a protocol has very well-defined semantics for
9
9
dealing with proxies, and this contributed to the widespread deployment
@@ -22,34 +22,33 @@ Proxies
22
22
23
23
Proxies provide a way to use server P (the middleman) to contact server
24
24
A and then route the response back to you. In more nefarious circles,
25
- it' s a prime way to make your presence unknown and pose as many clients
25
+ it’ s a prime way to make your presence unknown and pose as many clients
26
26
to a website instead of just one client. Often times websites will block
27
27
IPs that make too many requests, and proxies is a way to get around
28
- this. But even for simulating an attack, you should know how it' s done.
28
+ this. But even for simulating an attack, you should know how it’ s done.
29
29
30
30
User Agent
31
31
----------
32
32
33
33
Surprisingly, the only thing that tells a server the application
34
34
triggered the request (like browser type or from a script) is a header
35
- called a " user agent" which is included in the HTTP request.
35
+ called a “ user agent” which is included in the HTTP request.
36
36
37
37
The source code
38
38
---------------
39
39
40
40
The project code in this repository is crawling **five ** different
41
41
public proxy websites: \* http://proxyfor.eu/geo.php \*
42
42
http://free-proxy-list.net \* http://rebro.weebly.com/proxy-list.html \*
43
- http://www.samair.ru/proxy/time-01.htm \*
44
- https://www.sslproxies.org
43
+ http://www.samair.ru/proxy/time-01.htm \* https://www.sslproxies.org
45
44
46
45
After collecting the proxy data and filtering the slowest ones it is
47
46
randomly selecting one of them to query the target url. The request
48
47
timeout is configured at 30 seconds and if the proxy fails to return a
49
48
response it is deleted from the application proxy list. I have to
50
49
mention that for each request a different agent header is used. The
51
- different headers are stored in the **/data/user \_ agents .txt ** file
52
- which contains around 900 different agents.
50
+ different headers are stored in the **/data/user_agents .txt ** file which
51
+ contains around 900 different agents.
53
52
54
53
Installation
55
54
------------
@@ -59,13 +58,23 @@ tool <#command-line-interface>`__, install it globally via pip:
59
58
60
59
::
61
60
62
- pip install http-request-randomizer
61
+ pip install http-request-randomizer
63
62
64
63
Otherwise, you can clone the repository and use setup tools:
65
64
66
65
::
67
66
68
- python setup.py install
67
+ python setup.py install
68
+
69
+ Dev testing
70
+ -----------
71
+
72
+ Clone repo, install requirements, develop and run tests:
73
+
74
+ ::
75
+
76
+ pip install -r requirements.txt
77
+ tox -e pyDevVerbose
69
78
70
79
How to use
71
80
----------
@@ -83,37 +92,37 @@ show help message:
83
92
84
93
::
85
94
86
- proxyList -h, --help
95
+ proxyList -h, --help
87
96
88
97
specify proxy provider(s) (required):
89
98
90
99
::
91
100
92
- -s {proxyforeu,rebro,samair,freeproxy,all}
101
+ -s {proxyforeu,rebro,samair,freeproxy,all}
93
102
94
103
Specify output stream (default: sys.stdout), could also be a file:
95
104
96
105
::
97
106
98
- -o, --outfile
107
+ -o, --outfile
99
108
100
109
specify provider timeout threshold in seconds:
101
110
102
111
::
103
112
104
- -t, --timeout
113
+ -t, --timeout
105
114
106
115
specify proxy bandwidth threshold in KBs:
107
116
108
117
::
109
118
110
- -bw, --bandwidth
119
+ -bw, --bandwidth
111
120
112
- show program' s version number:
121
+ show program’ s version number:
113
122
114
123
::
115
124
116
- -v, --version
125
+ -v, --version
117
126
118
127
API
119
128
---
@@ -124,29 +133,29 @@ using a method call:
124
133
125
134
.. code :: python
126
135
127
- import time
128
- from http_request_randomizer.requests.proxy.requestProxy import RequestProxy
136
+ import time
137
+ from http_request_randomizer.requests.proxy.requestProxy import RequestProxy
129
138
130
- if __name__ == ' __main__' :
139
+ if __name__ == ' __main__' :
131
140
132
- start = time.time()
133
- req_proxy = RequestProxy()
134
- print (" Initialization took: {0} sec" .format((time.time() - start)))
135
- print (" Size: {0} " .format(len (req_proxy.get_proxy_list())))
136
- print (" ALL = {0} " .format(list (map (lambda x : x.get_address(), req_proxy.get_proxy_list()))))
141
+ start = time.time()
142
+ req_proxy = RequestProxy()
143
+ print (" Initialization took: {0} sec" .format((time.time() - start)))
144
+ print (" Size: {0} " .format(len (req_proxy.get_proxy_list())))
145
+ print (" ALL = {0} " .format(list (map (lambda x : x.get_address(), req_proxy.get_proxy_list()))))
137
146
138
- test_url = ' http://ipv4.icanhazip.com'
147
+ test_url = ' http://ipv4.icanhazip.com'
139
148
140
- while True :
141
- start = time.time()
142
- request = req_proxy.generate_proxied_request(test_url)
143
- print (" Proxied Request Took: {0} sec => Status: {1} " .format((time.time() - start), request.__str__ ()))
144
- if request is not None :
145
- print (" \t Response: ip={0} " .format(u ' ' .join(request.text).encode(' utf-8' )))
146
- print (" Proxy List Size: {0} " .format(len (req_proxy.get_proxy_list())))
149
+ while True :
150
+ start = time.time()
151
+ request = req_proxy.generate_proxied_request(test_url)
152
+ print (" Proxied Request Took: {0} sec => Status: {1} " .format((time.time() - start), request.__str__ ()))
153
+ if request is not None :
154
+ print (" \t Response: ip={0} " .format(u ' ' .join(request.text).encode(' utf-8' )))
155
+ print (" Proxy List Size: {0} " .format(len (req_proxy.get_proxy_list())))
147
156
148
- print (" -> Going to sleep.." )
149
- time.sleep(10 )
157
+ print (" -> Going to sleep.." )
158
+ time.sleep(10 )
150
159
151
160
Documentation
152
161
-------------
@@ -178,11 +187,11 @@ License
178
187
179
188
This project is licensed under the terms of the MIT license.
180
189
181
- .. |Build Status | image :: https://travis-ci.org /pgaref/HTTP_Request_Randomizer .svg?branch=master
182
- :target: https://travis-ci.org /pgaref/HTTP_Request_Randomizer
183
- .. |Coverage Status | image :: https://coveralls .io/repos/github/ pgaref/HTTP_Request_Randomizer/badge.svg?branch=master
184
- :target: https://coveralls.io/github/pgaref/HTTP_Request_Randomizer?branch=master
185
- .. |Dependency Status | image :: https://requires.io/github/pgaref/HTTP_Request_Randomizer/requirements.svg?branch=master
190
+ .. |Build Status | image :: https://github.com /pgaref/http_request_randomizer/workflows/CI/badge .svg
191
+ :target: https://github.com /pgaref/http_request_randomizer/actions
192
+ .. |codecov | image :: https://codecov .io/gh/ pgaref/HTTP_Request_Randomizer/branch/master/graph/ badge.svg?token=FjHh47wdYV
193
+ :target: undefined
194
+ .. |Requirements Status | image :: https://requires.io/github/pgaref/HTTP_Request_Randomizer/requirements.svg?branch=master
186
195
:target: https://requires.io/github/pgaref/HTTP_Request_Randomizer/requirements/?branch=master
187
196
.. |PyPI version | image :: https://badge.fury.io/py/http-request-randomizer.svg
188
197
:target: https://badge.fury.io/py/http-request-randomizer
0 commit comments