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
function throttle( fn, time ) { | |
var t = 0; | |
return function() { | |
var args = arguments, ctx = this; | |
clearTimeout(t); | |
t = setTimeout( function() { | |
fn.apply( ctx, args ); | |
}, time ); | |
}; |
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 | |
#!/usr/bin/env python | |
#coding=utf-8 | |
import urllib2 | |
import re | |
import MySQLdb | |
import thread | |
import time | |
#创建锁,用于访问数据库 |
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
import web | |
import MySQLdb | |
db = web.database(dbn='mysql',user='root',pw='root',db='python_test') #连接数据库 | |
render = web.template.render('templates/') #模板路径 | |
urls = ( #url设置 | |
'/','index', | |
'/page/(\d+)','index' | |
) |
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 sys | |
import urllib2 | |
import re | |
import os | |
def extract_url(info): | |
rege="http://news.qq.com/a/\d{8}/\d{6}.htm" | |
re_url = re.findall(rege, info) | |
return re_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
#-*-coding=gbk -*- | |
import os | |
import time | |
def listDir(fileDir): | |
for eachFile in os.listdir(fileDir): | |
if os.path.isfile(fileDir+"/"+eachFile): #如果是文件,判断最后修改时间,符合条件进行删除 | |
ft = os.stat(fileDir+"/"+eachFile); | |
ltime = int(ft.st_mtime); #获取文件最后修改时间 | |
#print "文件"+path+"/"+eachFile+"的最后修改时间为"+str(ltime); |
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/python | |
import MySQLdb | |
class SpiderPDO: | |
def __init__(self): | |
db_host = '127.0.0.1' | |
db_user = 'root' | |
db_pass = '666666' | |
db_name = 'db01' | |
conn = MySQLdb.connect(db_host, db_user, db_pass, db_name, charset = 'utf8') |
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 python2 | |
# -*- coding: utf-8 -*- | |
from weibo import APIClient | |
import urllib | |
import requests | |
# 个人信息 | |
__author__ = 'GentlemanMod' | |
__email__ = 'GentlemanMod@gmail.com' | |
__version__ = 'v1' |
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
import platform | |
print platform.platform() | |
print platform.version() | |
print platform.architecture() | |
print platform.machine() | |
print platform.node() | |
print platform.processor() | |
print platform.uname() | |
print platform.uname()[0] | |
print platform.python_build() |
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
import getpass | |
print getpass.getuser() |
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
''' | |
Created on 2013-8-23 | |
@author: codegeek | |
''' | |
def bubble_sort(seq): | |
for i in range(len(seq)): | |
for j in range(i,len(seq)): | |
if seq[j] < seq[i]: | |
tmp = seq[j] |
OlderNewer