摘要: #需要检查一个“目录”,或者某个包含子目录的目录树,并根据某种模式迭代所有的文件(也可能包含子目录)使用的是os.walk生成器import os, fnmatchdef all_files(root, patterns = '*', single_level = False, yield_folders=False): patterns = patterns.split(';') for path, subdirs, files in os.walk(root): if yield_folders: files.extend(subdirs) ... 阅读全文
posted @ 2012-08-12 23:44 苍术厚朴 阅读(2974) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python# author: Hua Liang [ Stupid ET ]# email: et@everet.org# website: http://EverET.org## Rule Of Optimization: Prototype before p... 阅读全文
posted @ 2012-08-12 21:54 苍术厚朴 阅读(6629) 评论(3) 推荐(1) 编辑
摘要: #!/usr/bin/env python# author: Hua Liang [ Stupid ET ]# email: et@everet.org# website: http://EverET.org#import socket, os, stat, threading, time, struct, getoptimport sys, re, signal, select, logging, logging.handlershost = '127.0.0.1'port = 21limit_connection_number = 5 # max client number 阅读全文
posted @ 2012-08-12 21:52 苍术厚朴 阅读(5444) 评论(0) 推荐(0) 编辑
摘要: # -*-coding:utf-8-*-# 作者:华亮#import urllibimport urllib2import refrom HTMLParser import HTMLParser# 获取QQ空间博客列表class QQBlogList(HTMLParser): in_key_div = False in_ul = False in_li = False in_a = False blogList = [] lasturl = '' def handle_starttag(self, tag, attrs): att... 阅读全文
posted @ 2012-08-12 21:46 苍术厚朴 阅读(929) 评论(0) 推荐(0) 编辑
摘要: """A parser for HTML and XHTML.""" 2 3 # This file is based on sgmllib.py, but the API is slightly different. 4 5 # XXX There should be a way to distinguish between PCDATA (parsed 6 # character data -- the normal case), RCDATA (replaceable character 7 # data -- only cha 阅读全文
posted @ 2012-08-12 21:38 苍术厚朴 阅读(515) 评论(0) 推荐(0) 编辑
摘要: Source code: Lib/HTMLParser.pyThis module defines a class HTMLParser which serves as the basis for parsing text files formatted in HTML (HyperText Mark-up Language) and XHTML. Unlike the parser in htmllib, this parser is not based on the SGML parser in sgmllib.class HTMLParser.HTMLParserAn HTMLParse 阅读全文
posted @ 2012-08-12 21:36 苍术厚朴 阅读(583) 评论(0) 推荐(0) 编辑
摘要: 文档:http://docs.python.org/library/pdb.htmlThe debugger recognizes the following commands. Most commands can be abbreviated to one or two letters; e.g. h(elp) means that either h or help can be used to enter the help command (but not he or hel, nor H or Help or HELP). Arguments to commands must be se 阅读全文
posted @ 2012-08-12 16:26 苍术厚朴 阅读(634) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: utf-8 -*-# Copyright 2012 splinter authors. All rights reserved.# Use of this source code is governed by a BSD-style# license that can be found in the LICENSE file.from __future__ import with_statementfrom splinter.driver import ElementAPIfrom splinter.element_list import ElementListcl 阅读全文
posted @ 2012-08-12 16:01 苍术厚朴 阅读(1635) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: utf-8 -*-# Copyright 2012 splinter authors. All rights reserved.# Use of this source code is governed by a BSD-style# license that can be found in the LICENSE file.from __future__ import with_statementimport loggingimport subprocessimport timeimport refrom contextlib import contextmana 阅读全文
posted @ 2012-08-12 15:52 苍术厚朴 阅读(3470) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: utf-8 -*-:# Copyright 2012 splinter authors. All rights reserved.# Use of this source code is governed by a BSD-style# license that can be found in the LICENSE file."""This module contains the basic API for splinter drivers and elemnts."""from splinter.wit 阅读全文
posted @ 2012-08-12 15:45 苍术厚朴 阅读(1715) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python# Copyright 2012 splinter authors. All rights reserved.# Use of this source code is governed by a BSD-style# license that can be found in the LICENSE file.import unittestfrom splinter import Browserclass TestGoogleSearch(unittest.TestCase): @classmethod def setUpClass(cls)... 阅读全文
posted @ 2012-08-12 15:41 苍术厚朴 阅读(478) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: utf-8 -*-# Copyright 2012 splinter authors. All rights reserved.# Use of this source code is governed by a BSD-style# license that can be found in the LICENSE file."""This snippet show how to "test" a Facebook feature: the creation of an event.It creates an eve 阅读全文
posted @ 2012-08-12 15:39 苍术厚朴 阅读(622) 评论(0) 推荐(0) 编辑
摘要: 作为脚本语言Python上手容易,但要学好Python能写出一手漂亮的、Pythonic的Python代码并非一日之功,本文的目的在于推荐一些优秀的Python相关的文章(至于书大家可以看dip、learning python和官方手册去),让你在成长为一名Python高手的路上少走一点弯路。注:文章都是英文的,学好Python读懂英文资料这是必须的了。1. PEP8 Style Guide for Python Code排第一的当属Python的编码规范PEP8,这个就不用我多说吧,无论是初学还是高手PEP8都是必须烂熟于胸的。在遵循里面讲述的规则的同时,大家也要记住两句比较特殊的话,不过这 阅读全文
posted @ 2012-08-12 11:41 苍术厚朴 阅读(1135) 评论(0) 推荐(2) 编辑
摘要: 为了防止下面的过程出错,建议:sudo apt-get install build-essential python-dev libxml2-dev libxslt1-dev1.下载splinter 0.4.7.tar.gz包http://pypi.python.org/pypi/splinter/0.4.72.解压 tar -zxvf 安装包 进入cd splinter 0.4.73.安装 sudo python setup.py install ImportError: No module named setuptools wgethttp://pypi.python.org/packag 阅读全文
posted @ 2012-08-12 11:27 苍术厚朴 阅读(1403) 评论(2) 推荐(0) 编辑