Skip to content

Commit f56ba23

Browse files
author
pgaref
committed
2 parents f3a0ca9 + c0f8f56 commit f56ba23

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

README-vi.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# HTTP Request Randomizer [![Build Status](https://travis-ci.org/pgaref/HTTP_Request_Randomizer.svg?branch=master)](https://travis-ci.org/pgaref/HTTP_Request_Randomizer) [![Coverage Status](https://coveralls.io/repos/github/pgaref/HTTP_Request_Randomizer/badge.svg?branch=master)](https://coveralls.io/github/pgaref/HTTP_Request_Randomizer?branch=master) [![Dependency Status](https://gemnasium.com/badges/github.com/pgaref/HTTP_Request_Randomizer.svg)](https://gemnasium.com/github.com/pgaref/HTTP_Request_Randomizer) [![PyPI version](https://badge.fury.io/py/http-request-randomizer.svg)](https://badge.fury.io/py/http-request-randomizer)
2+
3+
[View English version of this file here](README.md)
4+
5+
Thư viện này cung cấp để cải tiến cách thực thi các request HTTP của thư viện **requests** trong Python. Một trong những tính năng rất cần thiết đó là hỗ trợ proxy. HTTP được thiết kế rất tốt để làm việc với proxy.
6+
7+
Proxy rất hữu ích khi làm các công việc liên quan đến thu thập dữ liệu web hoặc đơn giản là khi bạn muốn ẩn danh (anomization).
8+
9+
Trong dự án này tôi sử dụng các proxy được cung cấp trên mạng và sử dụng nhiều user-agent khác nhau để gửi các request http bằng những IP ngẫu nhiên.
10+
11+
## Proxy là gì
12+
13+
Proxy cho phép sử dụng máy chủ P (trung gian) để liên lạc với máy chủ A và sau đó phản hồi lại cho bạn kết quả. Một cách nói khác, việc này giúp ẩn đi sự hiện diện của bạn khi truy cập vào một trang web, website sẽ hiểu đây là truy cập từ nhiều người thay vì chỉ một người duy nhất.
14+
15+
Thông thường, các trang web sẽ chặn các địa chỉ IP gửi quá nhiều request, và proxy là một cách để giải quyết vấn đề này. Bạn có thể lợi dụng proxy để thực hiện tấn công một website, nhưng tốt hơn bạn nên hiểu cách proxy hoạt động như thế nào ;)
16+
17+
## User-Agent là gì
18+
19+
User-agent chỉ là một giá trị gửi kèm trong HTTP request để giúp máy chủ web có thể giả lập trình duyệt và gửi yêu cầu đến một website bất kỳ.
20+
21+
## Mã nguồn
22+
23+
Mã nguồn trong repository này sẽ thực hiện lấy proxy từ **bốn** website khác nhau:
24+
* http://proxyfor.eu/geo.php
25+
* http://free-proxy-list.net
26+
* http://rebro.weebly.com/proxy-list.html
27+
* http://www.samair.ru/proxy/time-01.htm
28+
29+
Sau khi thu thập danh sách các proxy và loại bỏ những proxy chậm nó sẽ lấy ngẫu nhiên một proxy để gửi request đến url được chỉ định.
30+
Thời gian chờ được thiết lập là 30 giây và nếu proxy không phản hồi kết quả nó sẽ được xóa bỏ trong danh sách proxy.
31+
Tôi phải nhắc lại rằng mỗi request được gửi bằng một user-agent khác nhau, danh sách user-agent (khoảng 900 chuỗi khác nhau) được lưu trong file **/data/user_agents.txt**
32+
33+
## Làm sao để sử dụng?
34+
35+
Project này đã được phân phối như là một thư viện PyPI!
36+
Đây là phần source code mẫu cho việc sử dụng thư viện này. Bạn chỉ cần thêm **http-request-randomizer** vào file requirements.txt và chạy đoạn code dưới đây:
37+
38+
````python
39+
import time
40+
from http_request_randomizer.requests.proxy.requestProxy import RequestProxy
41+
42+
if __name__ == '__main__':
43+
44+
start = time.time()
45+
req_proxy = RequestProxy()
46+
print("Initialization took: {0} sec".format((time.time() - start)))
47+
print("Size: {0}".format(len(req_proxy.get_proxy_list())))
48+
print("ALL = {0} ".format(req_proxy.get_proxy_list()))
49+
50+
test_url = 'http://ipv4.icanhazip.com'
51+
52+
while True:
53+
start = time.time()
54+
request = req_proxy.generate_proxied_request(test_url)
55+
print("Proxied Request Took: {0} sec => Status: {1}".format((time.time() - start), request.__str__()))
56+
if request is not None:
57+
print("\t Response: ip={0}".format(u''.join(request.text).encode('utf-8')))
58+
print("Proxy List Size: {0}".format(len(req_proxy.get_proxy_list())))
59+
60+
print("-> Going to sleep..")
61+
time.sleep(10)
62+
````
63+
64+
## Tài liệu
65+
66+
[http-request-randomizer documentation](http://pythonhosted.org/http-request-randomizer)
67+
68+
69+
## Đóng góp
70+
71+
Mọi đóng góp của bạn luôn được trân trọng. Đừng ngần ngại gửi pull request cho chúng tôi.
72+
73+
## Bạn gặp vấn đề với thư viện này?
74+
75+
Hãy nêu lên vấn đề của bạn [tại đây](https://github.com/pgaref/HTTP_Request_Randomizer/issues), và càng chi tiết càng tốt. Chúng tôi sẽ hỗ trợ bạn trong sớm nhất có thể :)
76+
77+
## Giấy phép
78+
79+
Dự án này được cấp phép theo các điều khoản của giấy phép MIT.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# HTTP Request Randomizer [![Build Status](https://travis-ci.org/pgaref/HTTP_Request_Randomizer.svg?branch=master)](https://travis-ci.org/pgaref/HTTP_Request_Randomizer) [![Coverage Status](https://coveralls.io/repos/github/pgaref/HTTP_Request_Randomizer/badge.svg?branch=master)](https://coveralls.io/github/pgaref/HTTP_Request_Randomizer?branch=master) [![Dependency Status](https://gemnasium.com/badges/github.com/pgaref/HTTP_Request_Randomizer.svg)](https://gemnasium.com/github.com/pgaref/HTTP_Request_Randomizer) [![PyPI version](https://badge.fury.io/py/http-request-randomizer.svg)](https://badge.fury.io/py/http-request-randomizer)
22

3+
[View Vietnamese version of this file here](README-vi.md)
4+
35
A convenient way to implement HTTP requests is using Pythons' **requests** library.
46
One of requests’ most popular features is simple proxying support.
57
HTTP as a protocol has very well-defined semantics for dealing with proxies, and this contributed to the widespread deployment of HTTP proxies

0 commit comments

Comments
 (0)