View gist:d80a298e2af679429dd4
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
url = 'http://www.xxoo.com/' | |
req = urllib2.Request(url) | |
req.add_header('Accept-Encoding', 'gzip, deflate'); | |
f = urllib2.urlopen(req, timeout=30) | |
html = f.read() | |
if html[:6] == '\x1f\x8b\x08\x00\x00\x00': | |
html = gzip.GzipFile(fileobj = cStringIO.StringIO(html)).read() | |
html.decode('gbk') | |
a = html.decode('gbk') | |
print a |
View pachong.py
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
#coding:utf-8 | |
import re | |
import requests | |
url = 'http://pachong.org/high.html' | |
req = requests.get(url) | |
if req.status_code == 200: | |
html = req.text |
View result
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
i am function g | |
i am function f | |
('my parent function is', 'g') | |
i am function k | |
i am function f | |
('my parent function is', 'k') |
View for_mutouren.py
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
#coding:utf-8 | |
import os | |
import urllib | |
from pyquery import PyQuery | |
# 下载某个 url 中的所有图片 到 指定目录 | |
def get_img_and_save(url, target_dir): | |
pyobj = PyQuery(url) | |
img_objs = pyobj('img') |
View raw_http
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
#!/usr/bin/env python | |
#------------------------------------------------------------------------------- | |
# Name: raw_http.py | |
# Purpose: construct a raw http get packet | |
# | |
# Author: Yangjun | |
# | |
# Created: 08/02/2014 | |
# Copyright: (c) Yangjun 2014 |
View xls_col_to_num.py
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
#-*- coding: UTF-8 -*- | |
# author : recall404 | |
# email : tk657309822@gmail.com | |
""" | |
将 xls 文件对应的列由字母转换为数字,方便 xlrd 等读取数据 | |
源代码是从 XlsxWriter 中 copy 的 | |
并做了两个小修改: | |
1. 忽略大小写 |
View supervisord.service
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
[Unit] | |
Description=supervisord - Supervisor process control system for UNIX | |
Documentation=http://supervisord.org | |
After=network.target | |
[Service] | |
Type=forking | |
ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf | |
ExecReload=/usr/bin/supervisorctl reload | |
ExecStop=/usr/bin/supervisorctl shutdown |
View sublime text setting
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
{ | |
"default_line_ending": "unix", | |
"draw_white_space": "all", | |
"font_face": "Source Code Pro", | |
"font_size": 18, | |
"ignored_packages": | |
[ | |
"Jedi - Python autocompletion", | |
"Vintage" | |
], |
View novel_spider.py
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
# -*- coding: utf-8 -*- | |
import re | |
import scrapy | |
from scrapy.utils.response import get_base_url | |
from pyquery import PyQuery | |
from biquge.items import BiqugeItem |
View deploy.sh
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
#!/bin/bash | |
docs_dir=/home/recall/docker_data/nginx/scrapy-docs-cn | |
git=/usr/bin/git | |
branch=master | |
cd $docs_dir | |
$git reset --hard origin/$branch | |
$git clean -f |
OlderNewer