10
10
11
11
##### [ 介绍文档] ( https://github.com/jhao104/proxy_pool/blob/master/doc/introduce.md )
12
12
13
- * 支持版本 ![ ] ( https://img.shields.io/badge/Python-2.x-green.svg ) ![ ] ( https://img.shields.io/badge/Python-3.x-blue.svg )
13
+ * 支持版本: ![ ] ( https://img.shields.io/badge/Python-2.x-green.svg ) ![ ] ( https://img.shields.io/badge/Python-3.x-blue.svg )
14
14
15
- * 测试地址: http://123.207.35.36:5010 单机勿压测。谢谢
15
+ * 测试地址: http://123.207.35.36:5010 (单机勿压。感谢)
16
16
17
17
### 下载安装
18
18
@@ -67,9 +67,9 @@ port = 5010 # 监听端口
67
67
68
68
### 使用
69
69
70
- 启动过几分钟后就能看到抓取到的代理IP,你可以直接到数据库中查看,推荐一个[ SSDB可视化工具] ( https://github.com/jhao104/SSDBAdmin ) 。
70
+ 启动过几分钟后就能看到抓取到的代理IP,你可以直接到数据库中查看,推荐一个[ SSDB可视化工具] ( https://github.com/jhao104/SSDBAdmin ) 。
71
71
72
- 也可以通过api访问http://127.0.0.1:5010 查看。
72
+ 也可以通过api访问http://127.0.0.1:5010 查看。
73
73
74
74
* Api
75
75
@@ -83,7 +83,7 @@ port = 5010 # 监听端口
83
83
84
84
* 爬虫使用
85
85
86
- 如果要在爬虫代码中使用的话, 可以将此api封装成函数直接使用,例如:
86
+ 如果要在爬虫代码中使用的话, 可以将此api封装成函数直接使用,例如:
87
87
88
88
``` python
89
89
import requests
@@ -112,19 +112,59 @@ def getHtml():
112
112
return None
113
113
```
114
114
115
+ ### 扩展代理
116
+
117
+ 项目默认包含几个免费的代理获取方法,但是免费的毕竟质量不好,所以如果直接运行可能拿到的代理质量不理想。所以,提供了代理获取的扩展方法。
118
+
119
+ 添加一个新的代理获取方法如下:
120
+
121
+ * 1、首先在[ GetFreeProxy] ( https://github.com/jhao104/proxy_pool/blob/b9ccdfaada51b57cfb1bbd0c01d4258971bc8352/ProxyGetter/getFreeProxy.py#L32 ) 类中添加你的获取代理的静态方法,
122
+ 该方法需要以生成器(yield)形式返回` host:ip ` 格式的代理,例如:
123
+
124
+ ``` python
125
+
126
+ class GetFreeProxy (object ):
127
+ # ....
128
+
129
+ # 你自己的方法
130
+ @ staticmethod
131
+ def freeProxyCustom (): # 命名不和已有重复即可
132
+
133
+ # 通过某网站或者某接口或某数据库获取代理 任意你喜欢的姿势都行
134
+ # 假设你拿到了一个代理列表
135
+ proxies = [" 139.129.166.68:3128" , " 139.129.166.61:3128" , ... ]
136
+ for proxy in proxies:
137
+ yield proxy
138
+ # 确保每个proxy都是 host:ip正确的格式就行
139
+ ```
140
+
141
+ * 2、添加好方法后,修改Config.ini文件中的` [ProxyGetter] ` 项:
142
+
143
+ 在` Config.ini ` 的` [ProxyGetter] ` 下添加自定义的方法的名字:
144
+
145
+ ``` shell
146
+ [ProxyGetter]
147
+ ; register the proxy getter function
148
+ freeProxyFirst = 0 # 如果要取消某个方法,将其删除或赋为0即可
149
+ ....
150
+ freeProxyCustom = 1 # 确保名字和你添加方法名字一致
151
+ ` ` `
152
+
153
+ ` ProxyRefreshSchedule` 会每隔一段时间抓取一次代理,下次抓取时会自动识别调用你定义的方法。
154
+
115
155
# ## 问题反馈
116
156
117
- 任何问题欢迎在[ Issues] ( https://github.com/jhao104/proxy_pool/issues ) 中反馈,如果没有账号可以去 我的[ 博客] ( http://www.spiderpy.cn/blog/message ) 中留言。
157
+ 任何问题欢迎在[Issues](https://github.com/jhao104/proxy_pool/issues) 中反馈,如果没有账号可以去 我的[博客](http://www.spiderpy.cn/blog/message)中留言。
118
158
119
- 你的反馈会让此项目变得更加完美。
159
+ 你的反馈会让此项目变得更加完美。
120
160
121
161
# ## 贡献代码
122
162
123
- 本项目仅作为基本的通用的代理池架构,不接收特有功能(当然,不限于特别好的idea)。
163
+ 本项目仅作为基本的通用的代理池架构,不接收特有功能(当然,不限于特别好的idea)。
124
164
125
- 本项目依然不够完善,如果发现bug或有新的功能添加,请在[ Issues] ( https://github.com/jhao104/proxy_pool/issues ) 中提交bug(或新功能)描述,在确认后提交你的代码。
165
+ 本项目依然不够完善,如果发现bug或有新的功能添加,请在[Issues](https://github.com/jhao104/proxy_pool/issues)中提交bug(或新功能)描述,在确认后提交你的代码。
126
166
127
- 这里感谢以下contributor的无私奉献:
167
+ 这里感谢以下contributor的无私奉献:
128
168
129
169
[@kangnwh](https://github.com/kangnwh)| [@bobobo80](https://github.com/bobobo80)| [@halleywj](https://github.com/halleywj)| [@newlyedward](https://github.com/newlyedward)| [@wang-ye](https://github.com/wang-ye)| [@gladmo](https://github.com/gladmo)| [@bernieyangmh](https://github.com/bernieyangmh)| [@PythonYXY](https://github.com/PythonYXY)| [@zuijiawoniu](https://github.com/zuijiawoniu)
130
170
0 commit comments