Skip to content

Instantly share code, notes, and snippets.

View zhwei's full-sized avatar
🌏
Remote working

ZHANG Wei zhwei

🌏
Remote working
View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "zhwei"
# 使用imgur的api上传图片并返回url
import urllib2
import urllib
import json
@zhwei
zhwei / generte.py
Created May 20, 2013 16:40
用python写的jekyll的使用脚本,主要是问了方便提交博客以及其他的个人需求
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import datetime
# TARGET_FILE = os.getcwd() + "/_posts/"
ROOT_FILE = "/home/zhwei/apps/jekyll_blog/"
TARGET_FILE = ROOT_FILE + "_posts/"
@zhwei
zhwei / cache_html.py
Created November 12, 2013 12:24
cache htmls in memory 静态网站加速 Python & bottle
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# import os
import md5
import bottle
#HTML = "output"
HTML = "/home/zhwei/blog"
@zhwei
zhwei / fabfile.py
Created March 18, 2014 12:41
Django项目中使用的fabfile, 其实也是通用的
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from fabric.colors import green, red
from fabric.contrib.console import confirm
from fabric.api import run, env, cd, put, sudo, abort
# configs
env.user = 'username'
env.hosts = ['IP:PORT',]
@zhwei
zhwei / gpa.py
Created May 12, 2014 12:22
计算学分绩点Python脚本
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import requests
data = {"post_xuehao": "111111789"}
page = requests.post('http://xkzx.sdut.edu.cn/cjcx/zcjcx_list.php', data=data)
par = re.compile('<td scope="col" align=".*" valign="middle" nowrap>&nbsp;(.*?)</td>')
@zhwei
zhwei / fetch_baixing.py
Created June 7, 2014 02:35
抓取百姓网指定城市中二手车栏目下一百个帖子的详细内容
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import sys
import time
import threading
try:
import requests
except ImportError:
@zhwei
zhwei / gotit-doc.md
Last active August 29, 2015 14:05
Gotit 开放接口文档

Gotit 开放接口文档

  • 更新时间: 2014-05-05
  • 数据格式均为JSON
  • 接口使用说明:
    1. 由于中文验证码的存在, 接口或许有点另类, 希望见谅.
    2. 验证类接口需要登录后才能使用, 如果仅查询单项信息推荐使用下面的成绩类或课表类接口
    3. 开发者在使用接口前先通过邮件联系作者 索要accesstoken, 将其放入请求header中.
    4. 次数限制 1000次/小时, 防止端口被恶意使用, 如果配额不够请联系作者.
@zhwei
zhwei / BaixingAPIv2.py
Last active August 29, 2015 14:05
百姓网开放APIv2 Python版SDK
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 百姓网开放APIv2 Python版SDK
# 支持 Python2.7+
# Author: [email protected]
# Date: 2014-08-13
# 开发文档:http://api.baixing.com.cn/developer/
import json
python-dev python3-dev
@zhwei
zhwei / rename_file.py
Created February 9, 2015 03:01
rename file script
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Rename: baixing.log-1420614280.gz => baixing.log-20150107-150440.gz
import os
import datetime
to_date = lambda x: datetime.datetime.fromtimestamp(int(x)).strftime('%Y%m%d-%H%M%S')
file_list = os.listdir(".")