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
times in msec | |
clock self+sourced self: sourced script | |
clock elapsed: other lines | |
000.011 000.011: --- NVIM STARTING --- | |
006.705 006.694: locale set | |
016.092 009.387: inits 1 | |
016.122 000.030: window checked |
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
# 命令 | |
scrapy startproject tutorial | |
scrapy crawl dmoz # spider name: dmoz | |
scrapy shell 'http://www.example.com' # enter shell | |
# start | |
start_urls | |
# fisrt start | |
def start_requests(self): |
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 | |
# -*- coding: utf-8 -*- | |
import requests | |
import json | |
import os | |
import base64 | |
from Crypto.Cipher import AES | |
from pprint import pprint | |
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
r.requests('http://www.example.com') | |
r.request.headers # 请求头 | |
r.status_code | |
r.url # 访问网址 | |
r.headers # 返回头部信息 | |
r.encoding | |
r.text #内容部分(PS,由于编码问题,建议这里使用r.content) | |
r.json() |
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
def timeit(func, *args, **kw): | |
def wrap(): | |
print time.time() | |
func(*args, **kw) | |
print time.time() | |
return wrap |
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
#-*- encoding: UTF-8 -*- | |
#---------------------------------import------------------------------------ | |
import subprocess | |
import time | |
#--------------------------------------------------------------------------- | |
import os | |
import tempfile | |
mplayer_controller = os.path.join(tempfile.mkdtemp(), 'mplayer_controller') | |
os.mkfifo(mplayer_controller) | |
cmd = 'mplayer -slave -quiet -input file={fifo} {song_url}' |
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 | |
class Me(Developer) : | |
@property | |
def education(self): | |
return { | |
"Undergraduate" : ["Saftey Engineering","Shenyang Aerospace University"], | |
"Graduate" : ["Soft Engineering","Liaoning University"]} |