Browse Source

update readme

pull/4/merge
Germey 8 years ago
parent
commit
91cbbbfc9f
  1. 55
      README.md
  2. 2
      cookiespool/api.py
  3. 19
      cookiespool/config.py
  4. 2
      cookiespool/db.py
  5. 11
      cookiespool/generator.py
  6. 6
      cookiespool/scheduler.py
  7. 4
      cookiespool/verify.py
  8. 4
      importer.py
  9. 4
      requirements.txt

55
README.md

@ -1,3 +1,54 @@
# CookiesPool # CookiesPool / Cookies池
CookiesPool Based on Redis and Flask ## 安装
```
pip3 install -r requirements.txt
```
## 基础配置
修改cookiespool/config.py
### 数据库配置
account:weibo:账号
cookies:weibo:账号
类型都是list,内容分别为密码和Cookies
![](https://ww1.sinaimg.cn/large/006tNbRwly1ff506wv38aj30jj05sq32.jpg)
![](https://ww4.sinaimg.cn/large/006tNbRwly1ff507mobqcj30ra06sweu.jpg)
账号自行某宝购买
Redis连接信息到cookiespool/config文件修改
### 云打码平台配置
到yundama.com注册开发者和普通用户。
开发者申请应用ID和KEY,普通用户用于充值登录。
配置信息到cookiespool/config文件修改
### 进程开关
配置信息到cookiespool/config文件修改
## 运行
```
python3 run.py
```
## 批量导入
```
python3 importer.py
```
![](https://ww2.sinaimg.cn/large/006tNbRwly1ff50gt9j0hj30r20jy763.jpg)

2
cookiespool/api.py

@ -1,6 +1,6 @@
from flask import Flask, g from flask import Flask, g
from cookiespool.config import * from cookiespool.config import *
from cookiespool.db import CookiesRedisClient, AccountRedisClient
__all__ = ['app'] __all__ = ['app']

19
cookiespool/config.py

@ -1,36 +1,36 @@
# Redis数据库地址 # Redis数据库地址
REDIS_HOST = 'localhost' REDIS_HOST = 'localhost'
# Redis端口
REDIS_PORT = 6379 REDIS_PORT = 6379
# Redis密码,如无填None
REDIS_PASSWORD = 'foobared' REDIS_PASSWORD = 'foobared'
# 配置信息,无需修改
REDIS_DOMAIN = '*' REDIS_DOMAIN = '*'
REDIS_NAME = '*' REDIS_NAME = '*'
# 云打码相关配置到yundama.com申请注册 # 云打码相关配置到yundama.com申请注册
YUNDAMA_USERNAME = 'Germey' YUNDAMA_USERNAME = 'Germey'
YUNDAMA_PASSWORD = '' YUNDAMA_PASSWORD = ''
YUNDAMA_APP_ID = '3372' YUNDAMA_APP_ID = '3372'
YUNDAMA_APP_KEY = '1b586a30bfda5c7fa71c881075ba49d0' YUNDAMA_APP_KEY = '1b586a30bfda5c7fa71c881075ba49d0'
YUNDAMA_API_URL = 'http://api.yundama.com/api.php' YUNDAMA_API_URL = 'http://api.yundama.com/api.php'
# 云打码最大尝试次数
YUNDAMA_MAX_RETRY = 20 YUNDAMA_MAX_RETRY = 20
# 产生器默认使用的浏览器 # 产生器默认使用的浏览器
DEFAULT_BROWSER = 'PhantomJS' DEFAULT_BROWSER = 'PhantomJS'
# 产生器类 # 产生器类,如扩展其他站点,请在此配置
GENERATOR_MAP = { GENERATOR_MAP = {
'weibo': 'WeiboCookiesGenerator' 'weibo': 'WeiboCookiesGenerator'
} }
# 测试类 # 测试类,如扩展其他站点,请在此配置
TESTER_MAP = { TESTER_MAP = {
'weibo': 'WeiboValidTester' 'weibo': 'WeiboValidTester'
} }
@ -40,13 +40,12 @@ CYCLE = 120
# API地址和端口 # API地址和端口
API_HOST = '127.0.0.1' API_HOST = '127.0.0.1'
API_PORT = 5000 API_PORT = 5000
# 进程开关 # 进程开关
# 产生器 # 产生器,模拟登录添加Cookies
GENERATOR_PROCESS = True GENERATOR_PROCESS = True
# 验证器 # 验证器,循环检测数据库中Cookies是否可用,不可用删除
VALID_PROCESS = False VALID_PROCESS = False
# API # API接口服务
API_PROCESS = True API_PROCESS = True

2
cookiespool/db.py

@ -1,5 +1,7 @@
import random import random
import redis import redis
from cookiespool.config import * from cookiespool.config import *
from cookiespool.error import * from cookiespool.error import *

11
cookiespool/generator.py

@ -1,17 +1,16 @@
import json import json
import requests import requests
import time
from selenium import webdriver from selenium import webdriver
from selenium.webdriver import DesiredCapabilities
from selenium.common.exceptions import WebDriverException, TimeoutException from selenium.common.exceptions import WebDriverException, TimeoutException
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from cookiespool.config import *
from cookiespool.db import CookiesRedisClient, AccountRedisClient from cookiespool.db import CookiesRedisClient, AccountRedisClient
from cookiespool.verify import Yundama from cookiespool.verify import Yundama
from cookiespool.config import *
from requests.exceptions import ConnectionError
class CookiesGenerator(object): class CookiesGenerator(object):

6
cookiespool/scheduler.py

@ -1,10 +1,8 @@
import time import time
from multiprocessing import Process from multiprocessing import Process
from cookiespool.tester import *
from cookiespool.config import *
from cookiespool.api import app from cookiespool.api import app
import os from cookiespool.config import *
import signal
class Scheduler(object): class Scheduler(object):

4
cookiespool/verify.py

@ -1,6 +1,8 @@
import requests
import time import time
import requests
from requests.exceptions import ConnectionError from requests.exceptions import ConnectionError
from cookiespool.config import * from cookiespool.config import *

4
importer.py

@ -0,0 +1,4 @@
from cookiespool.importer import scan
if __name__ == '__main__':
scan()

4
requirements.txt

@ -0,0 +1,4 @@
requests>=2.13.0
selenium>=3.4.0
redis>=2.10.5
Flask>=0.12.1
Loading…
Cancel
Save