Skip to content

Commit e08d4b1

Browse files
author
jinghao_wb
committed
[update]文档
1 parent b9ccdfa commit e08d4b1

File tree

1 file changed

+50
-10
lines changed

1 file changed

+50
-10
lines changed

README.md

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
##### [介绍文档](https://github.com/jhao104/proxy_pool/blob/master/doc/introduce.md)
1212

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)
1414

15-
* 测试地址: http://123.207.35.36:5010 单机勿压测。谢谢
15+
* 测试地址: http://123.207.35.36:5010 (单机勿压。感谢)
1616

1717
### 下载安装
1818

@@ -67,9 +67,9 @@ port = 5010 # 监听端口
6767

6868
### 使用
6969

70-
启动过几分钟后就能看到抓取到的代理IP,你可以直接到数据库中查看,推荐一个[SSDB可视化工具](https://github.com/jhao104/SSDBAdmin)
70+
  启动过几分钟后就能看到抓取到的代理IP,你可以直接到数据库中查看,推荐一个[SSDB可视化工具](https://github.com/jhao104/SSDBAdmin)
7171

72-
也可以通过api访问http://127.0.0.1:5010 查看。
72+
  也可以通过api访问http://127.0.0.1:5010 查看。
7373

7474
* Api
7575

@@ -83,7 +83,7 @@ port = 5010 # 监听端口
8383

8484
* 爬虫使用
8585

86-
如果要在爬虫代码中使用的话, 可以将此api封装成函数直接使用,例如:
86+
  如果要在爬虫代码中使用的话, 可以将此api封装成函数直接使用,例如:
8787

8888
```python
8989
import requests
@@ -112,19 +112,59 @@ def getHtml():
112112
return None
113113
```
114114

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+
115155
### 问题反馈
116156
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)中留言。
118158
119-
你的反馈会让此项目变得更加完美。
159+
  你的反馈会让此项目变得更加完美。
120160
121161
### 贡献代码
122162
123-
本项目仅作为基本的通用的代理池架构,不接收特有功能(当然,不限于特别好的idea)。
163+
  本项目仅作为基本的通用的代理池架构,不接收特有功能(当然,不限于特别好的idea)。
124164
125-
本项目依然不够完善,如果发现bug或有新的功能添加,请在[Issues](https://github.com/jhao104/proxy_pool/issues)中提交bug(或新功能)描述,在确认后提交你的代码。
165+
  本项目依然不够完善,如果发现bug或有新的功能添加,请在[Issues](https://github.com/jhao104/proxy_pool/issues)中提交bug(或新功能)描述,在确认后提交你的代码。
126166
127-
这里感谢以下contributor的无私奉献:
167+
  这里感谢以下contributor的无私奉献:
128168
129169
  [@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)
130170

0 commit comments

Comments
 (0)