Skip to content

Commit

Permalink
Update: 文档及注释更新
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiandongx committed May 25, 2018
1 parent c2abb1a commit 84d1cda
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ REDIS_PORT = 6379
# redis 密码
REDIS_PASSWORD = None
# redis set key
REDIS_KEY = "proxies"
REDIS_KEY = "proxies:ranking"
# redis 连接池最大连接量
REDIS_MAX_CONNECTION = 20
Expand Down Expand Up @@ -285,7 +285,7 @@ Keep-Alive: 5
```
### 扩展爬取网站
### 扩展代理爬取网站
在 crawler.py 文件里新增你自己的爬取方法。
```python
Expand All @@ -302,7 +302,15 @@ class Crawler:
# 爬取逻辑
```
### sanic 性能测试
### 选择其他 web 框架
本项目使用了 Sanic,但是开发者完全可以根据自己的需求选择其他 web 框架,web 模块是完全独立的,替换框架不会影响到项目的正常运行。需要如下步骤。
1. 在 [webapi.py](https://github.com/chenjiandongx/async-proxy-pool/blob/master/async_proxy_pool/webapi.py) 里更换框架。
2. 在 [server.py](https://github.com/chenjiandongx/async-proxy-pool/blob/master/server.py) 里修改 app 启动细节。
### Sanic 性能测试
使用 [wrk](https://github.com/wg/wrk) 进行服务器压力测试。基准测试 30 秒, 使用 12 个线程, 并发 400 个 http 连接。
Expand Down
2 changes: 1 addition & 1 deletion async_proxy_pool/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# redis 密码
REDIS_PASSWORD = None
# redis set key
REDIS_KEY = "proxies"
REDIS_KEY = "proxies:ranking"
# redis 连接池最大连接量
REDIS_MAX_CONNECTION = 20

Expand Down
4 changes: 4 additions & 0 deletions async_proxy_pool/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@


class RedisClient:
"""
代理池依赖了 Redis 数据库,使用了其`有序集合`的数据结构
(可按分数排序,key 值不能重复)
"""

def __init__(
self, host=REDIS_HOST, port=REDIS_PORT, password=REDIS_PASSWORD
Expand Down

0 comments on commit 84d1cda

Please sign in to comment.