
代码推荐
文章平均质量分 70
talkincode
这个作者很懒,什么都没留下…
展开
-
mysql备份脚本
#!/bin/bash USERNAME=root PASSWORD=root DBNAME=mydb DATE=`date +%Y-%m-%d` OLDDATE=`date +%Y-%m-%d -d '-20 days'` FTPOLDDATE=`date +%Y-%m-%d -d '-60 days'` MYSQL=/usr/local/mysql/bin/mysq原创 2012-09-06 11:31:01 · 536 阅读 · 0 评论 -
使用python破解密码
import os from commands import getoutput leet = { 'a': ('a', 'A', '4'), 'b': ('B', '3', '8'), 'c': ('c', 'C', 'k', 'K'), 'd': ('d', 'D', ), 'e': ('e', 'E', '3'), 'f': ('f',原创 2012-09-06 11:43:22 · 2120 阅读 · 0 评论 -
获取windows系统信息
import sysimport osimport ctypesimport _winreg def get_registry_value(key, subkey, value): if sys.platform != 'win32': raise OSError("get_registry_value is only supported on Windows")翻译 2012-09-06 11:41:54 · 772 阅读 · 1 评论 -
Gevent使用多进程例子
class GEventServer(): """ gevent wsgi服务器定义,可利用多进程 """ def __init__(self,handler,host,port): self.handler = handler self.host = host self.port = port def start原创 2012-09-06 11:23:50 · 3154 阅读 · 1 评论 -
IMAP邮件服务器附件处理
#------------------------------------------------------------------------------# Name: attdownload.py# Author: Suresh Kumar MP# Last Modified: 09/29/06# Description: This python script monitor转载 2012-09-06 11:41:02 · 1487 阅读 · 0 评论 -
python多线程下载器
import osimport urllib2import timeimport multiprocessing.dummy as multiprocessingimport stringfrom random import choiceimport socketfrom ctypes import c_intimport tempfile import dummyfrom原创 2012-09-06 11:32:01 · 776 阅读 · 0 评论 -
Tornado基于方法的url分发器
#!/usr/bin/env python# -*- coding: utf-8 -*-## Copyright 2009 Dan McDougall## Licensed under the Apache License, Version 2.0 (the "License"); you may# not use this file except in compliance with转载 2012-09-06 11:45:39 · 2224 阅读 · 0 评论 -
一个更高级的struct模块
import struct class Format(object): """Endianness and size format for structures.""" Native = "@" # Native format, native size StandardNative = "=" # Native format,翻译 2012-09-06 11:39:08 · 564 阅读 · 0 评论 -
一个scrapy抓取网站独立脚本
#!/usr/bin/env python# -*- coding: utf-8 -*-# author: Rolando Espinoza La fuente## Changelog:# 24/07/2011 - updated to work with scrapy 13.0dev# 25/08/2010 - initial version. works with翻译 2012-09-06 11:22:16 · 1402 阅读 · 0 评论 -
使用生成器遍历目录
from __future__ import generators import os def dirwalk(dir): "walk a directory tree, using a generator" for f in os.listdir(dir): fullpath = os.path.join(dir,f) if os.path原创 2012-09-06 11:51:30 · 586 阅读 · 0 评论 -
类似AWK的文本处理
import re class AwkUnhandledLine( RuntimeError ): pass class Awk: """awk-like mapping from patterns to handlers.""" def __init__(self): # Start without any patterns sel翻译 2012-09-06 11:36:47 · 658 阅读 · 0 评论 -
gevent实现基于端口转发的http代理服务器
在gevent的例子里有一个端口转发的例子,不过这个例子的地址都是直接指定的,比如运行:portforwarder.py 127.0.0.1:8080 www.baidu.com:80 通过修改下,我们可以实现动态的端口转发,从请求头分析出目标地址,然后动态建立端口转发,代码如下:import sysimport signalimport urlparseimp原创 2012-09-08 17:01:58 · 2182 阅读 · 0 评论