-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tangrela
committed
Jan 26, 2018
0 parents
commit 36b0213
Showing
25 changed files
with
2,020 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# dotenv | ||
.env | ||
|
||
# virtualenv | ||
.venv | ||
venv/ | ||
ENV/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 tangrela | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Tumblr解析网站搭建教程 | ||
1. 首先安装Python。linux自带了python,windows请自行下载python。推荐Centos7/Python2.7 | ||
2. 这时候,pip应该可以用了。如果不行,linux请按下面的命令安装pip: | ||
`wget https://bootstrap.pypa.io/get-pip.py && python get-pip.py` | ||
3. 安装依赖库:`pip install -r requirement.txt` | ||
4. 创建数据库:`python rebuildDB.py` | ||
5. 运行:`gunicorn -w4 -b 0.0.0.0:5000 run:app` | ||
|
||
然后访问 ip:5000 试试 | ||
如果不能访问,看看防火墙是否开了5000端口? | ||
|
||
------ | ||
|
||
## 以上都是基本的安装。 | ||
### 如果你需要使用MySQL | ||
修改`config.py`:注释第六行 --> 第五行开头#去掉,修改`user`、`passwd`、`database` | ||
|
||
### 配置自启动 | ||
1. 修改`supervisord.conf`,将`directory`修改为脚本根目录 | ||
2. echo "supervisord -c 网站根目录/supervisord.conf" >> /etc/rc.d/rc.local | ||
3. chmod +x /etc/rc.d/rc.local | ||
|
||
### 配置nginx | ||
修改nginx配置文件,添加`server` | ||
``` | ||
server { | ||
listen 80; | ||
server_name t.v4s0.us; #域名 | ||
charset utf-8; | ||
access_log /www/wwwlogs/t.v4s0.us.log; | ||
location / { | ||
proxy_pass http://127.0.0.1:5000; | ||
proxy_redirect off; | ||
proxy_set_header Host $host:80; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
} | ||
location /(images|javascript|js|css|flash|media|static)/ { | ||
root /root/tumblr_clawer/app/static; #目录修改好 | ||
expires 1d; | ||
} | ||
#error_page 404 /404.html; | ||
# redirect server error pages to the static page /50x.html | ||
# | ||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
root html; | ||
} | ||
} | ||
``` | ||
|
||
### 其他需求请加[qq群](https://jq.qq.com/?_wv=1027&k=5G8OtPx) | ||
|
||
------ | ||
示例网站:http://ojbk.us | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from flask import Flask | ||
from flask_sqlalchemy import SQLAlchemy | ||
from flask_bootstrap import Bootstrap | ||
#from celery import Celery,platforms | ||
from flask_pagedown import PageDown | ||
|
||
app = Flask(__name__) | ||
app.config.from_object('config') | ||
|
||
# Celery configuration | ||
#celery = Celery(__name__, broker=app.config['CELERY_BROKER_URL']) | ||
db = SQLAlchemy(app, use_native_unicode='utf8') | ||
bootstrap = Bootstrap(app) | ||
pagedown = PageDown(app) | ||
# celery.conf.update(app.config) | ||
#platforms.C_FORCE_ROOT = True | ||
|
||
from app import views |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# -*- coding: utf-8 -*- | ||
import random | ||
from PIL import Image, ImageDraw, ImageFont | ||
import StringIO | ||
import string | ||
|
||
|
||
class RandomChar(object): | ||
@staticmethod | ||
def Unicode(): | ||
"""用于随机生成汉字对应的Unicode字符""" | ||
#val = random.randint(0x4E00, 0x9FBB) | ||
# 只使用英文字母 | ||
val = random.randint(65, 90) | ||
return unichr(val) | ||
|
||
@staticmethod | ||
def GB2312(): | ||
head = random.randint(0xB0, 0xCF) | ||
body = random.randint(0xA, 0xF) | ||
tail = random.randint(0, 0xF) | ||
val = (head << 8) | (body << 4) | tail | ||
str = "%x" % val | ||
# | ||
return str.decode('hex').decode('gb2312', 'ignore') | ||
|
||
|
||
class ImageChar(): | ||
def __init__(self, fontColor=(0, 0, 0), | ||
size=(150, 50), | ||
fontPath='app/static/fonts/Rosewood_std_R.ttf', | ||
bgColor=(255, 255, 255, 255), | ||
fontSize=30): | ||
self.size = size | ||
self.fontPath = fontPath | ||
self.bgColor = bgColor | ||
self.fontSize = fontSize | ||
self.fontColor = fontColor | ||
self.font = ImageFont.truetype(self.fontPath, self.fontSize) | ||
self.image = Image.new('RGBA', size, bgColor) | ||
|
||
def rotate(self): | ||
img1 = self.image.rotate(random.randint(-1, 1), expand=0) | ||
# 默认为0,表示剪裁掉伸到画板外面的部分 | ||
img = Image.new('RGBA', img1.size, (255,) * 4) | ||
self.image = Image.composite(img1, img, img1) | ||
|
||
def drawText(self, pos, txt, fill): | ||
draw = ImageDraw.Draw(self.image) | ||
draw.text(pos, txt, font=self.font, fill=fill) | ||
del draw | ||
|
||
def randRGB(self): | ||
return (random.randint(0, 255), | ||
random.randint(0, 255), | ||
random.randint(0, 255)) | ||
|
||
def randPoint(self): | ||
(width, height) = self.size | ||
return (random.randint(0, width), random.randint(0, height)) | ||
|
||
def randLine(self, num): | ||
draw = ImageDraw.Draw(self.image) | ||
for i in range(0, num): | ||
draw.line([self.randPoint(), self.randPoint()], self.randRGB()) | ||
del draw | ||
|
||
def randChinese(self, num): | ||
gap = 0 | ||
start = 0 | ||
strRes = '' | ||
for i in range(0, num): | ||
char = RandomChar().Unicode() | ||
strRes += char | ||
x = start + self.fontSize * i + random.randint(0, gap) + gap * i | ||
self.drawText((x, 0), char, (0, 0, 0)) | ||
self.rotate() | ||
self.randLine(3) | ||
return strRes, self.image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#-*- coding=utf-8 -*- | ||
from app import db | ||
|
||
#Tumblr | ||
class ID(db.Model): | ||
__tablename__='id_table' | ||
id=db.Column(db.String(64),primary_key=True) | ||
parseTimes=db.Column(db.Integer,default=0) #解析次数 | ||
updateTime=db.Column(db.String(64)) #最近更新时间 | ||
|
||
def __init__(self,**kwargs): | ||
super(ID,self).__init__(**kwargs) | ||
|
||
def __repr__(self): | ||
return self.id | ||
|
||
# | ||
class Context(db.Model): | ||
__tablename__='context_table' | ||
id=db.Column(db.String(64),primary_key=True) | ||
urls=db.Column(db.String(200),primary_key=True) | ||
isvideo=db.Column(db.Integer,default=0) #0=no,1=yes | ||
poster=db.Column(db.String(200)) | ||
|
||
def __init__(self,id,urls,isvideo,poster): | ||
self.id=id | ||
self.urls=urls | ||
self.isvideo=isvideo | ||
self.poster=poster | ||
|
||
def __repr__(self): | ||
return self.id |
Binary file not shown.
Oops, something went wrong.