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
""" | |
A simple proxy server. Usage: | |
http://hostname:port/p/(URL to be proxied, minus protocol) | |
For example: | |
http://localhost:8080/p/www.google.com | |
""" |
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 -*- | |
# @Author: [email protected] | |
# @Last Modified time: 2016-06-12 23:46:06 | |
from time import clock | |
class Timer(object): | |
def __init__(self, verbose=False): | |
self.verbose = verbose |
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 -*- | |
# @Last Modified time: 2016-06-13 20:00:34 | |
orignal_str = "Profiling a Python program is doing a dynamic analysis"\ | |
"that measures the execution time of the program and"\ | |
"everything that compose it." | |
exec_times = 100000 | |
# @profile |
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 -*- | |
# @Author: [email protected] | |
# @Last Modified time: 2016-06-13 20:54:09 | |
import cProfile | |
from time_profile import * | |
import pstats | |
cProfile.run("timeit_profile()", "timeit") | |
p = pstats.Stats('timeit') |
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
@manager.command | |
def list_routes(): | |
"""List all the rules of route.""" | |
import urllib | |
output = [] | |
for rule in app.url_map.iter_rules(): | |
options = {} | |
for arg in rule.arguments: | |
options[arg] = "[{0}]".format(arg) |
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 | |
# According to: | |
# How To Set Up Python 2.7.6 and 3.3.3 on CentOS 6.4 | |
# https://www.digitalocean.com/community/tutorials/how-to-set-up-python-2-7-6-and-3-3-3-on-centos-6-4 | |
yum -y update | |
yum groupinstall -y 'development tools' | |
yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel | |
yum install xz-libs | |
wget http://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz |
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 -*- | |
# @Last Modified time: 2016-06-27 17:03:01 | |
import requests | |
from lxml import html as HTML | |
import os | |
import codecs | |
class KeyWordSite(object): |
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 -*- | |
# @Last Modified time: 2016-06-27 17:03:25 | |
from gevent import monkey | |
monkey.patch_all() | |
import time | |
import requests | |
from lxml import html as HTML | |
import gevent | |
from os.path import isfile |
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 -*- | |
# @Last Modified time: 2016-06-27 17:03:42 | |
import requests | |
import os | |
def get_speed_test(src_path, result_path, timeout=10): | |
all_sites = _get_sites_(src_path) | |
results = [] |
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 -*- | |
# @Last Modified time: 2016-06-28 10:50:58 | |
import urllib2 | |
import time | |
from threading import Thread | |
# 在大量访问url的时候,多线程很有优势,实际上也是空间换时间 | |
URLs = ["http://www.baidu.com", |