Skip to content

Instantly share code, notes, and snippets.

View taizilongxu's full-sized avatar
😭
I may be slow to respond.

hackerxu taizilongxu

😭
I may be slow to respond.
  • Qunar
  • Beijing
View GitHub Profile
#!/usr/bin/env python
class Me(Developer) :
@property
def education(self):
return {
"Undergraduate" : ["Saftey Engineering","Shenyang Aerospace University"],
"Graduate" : ["Soft Engineering","Liaoning University"]}
#-*- 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}'
@taizilongxu
taizilongxu / 123
Last active August 29, 2015 14:19
def timeit(func, *args, **kw):
def wrap():
print time.time()
func(*args, **kw)
print time.time()
return wrap
@taizilongxu
taizilongxu / requests.py
Created August 27, 2016 10:10
requests
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()
@taizilongxu
taizilongxu / music.py
Created August 27, 2016 15:03
163 music
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import json
import os
import base64
from Crypto.Cipher import AES
from pprint import pprint
@taizilongxu
taizilongxu / scrapy.py
Created September 3, 2016 10:03
scrapy常用
# 命令
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):
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