python 调用google翻译API进行文本翻译
'''Created on 2011-12-25For the graduation project's translationUpdated on 2011-12-26 http://www.unixuser.org/~euske/python/pdfminer/index.htmlUse PDFMiner to convert the .pdf to .txt,in order to make it easy to read the .txt files,and anoth... « 阅读全文
Python 写个Python程序 图片抓取
#!/usr/bin/env pythonfrom sgmllib import SGMLParserimport urllib2num = 1img_url = {}url_url = {}img_exist = {}style_img = ["jpg", "jpeg", "gif", "png", "bmp", "JPG", "JPEG", "GIF", "PNG", "BMP"] #要下载图片的格式 class parseList(SGMLParser): def reset(s... « 阅读全文
python常用模块,很强大,很犀利
python常用库(官网:http://docs.python.org/release/2.5.2/lib/lib.html)import os // 与操作系统相关的函数:如目录,文件,系统操作system,fork,exec族等等import sys // 一些系统参数和常见处理函数import subprocess // 替换os的一些老的开发函数如管道import multiprocessing // 进程间通信,如进程,消息队列,共享内存import threading //... « 阅读全文
py单词翻译小工具(python抓取html实现)
分类:Python2008-08-2915:57199人阅读评论(0)收藏举报正好把手头以前写的脚本整理下,完善了一下,大家看看玩把。原理很简单,都能看懂,就是发送个请求,解析下翻译结果。使用方法:[root@linux~]#pythonsmalldict.py fish输入:fish------... « 阅读全文
一个Python HTMLParser的使用例子
转贴2008年六月21日 by 贝贝爸 Leave a reply ? 原文 http://crquan.blogbus.com/logs/8269701.html #!/usr/bin/env python import sysimport urllibimport HTMLParser class CustomParser(HTMLParser.HTMLParser): selected = ('table', 'h1', 'font', 'ul', 'li', 'tr', ... « 阅读全文
python 检测编码 Universal Encoding De
用python检测文件的编码Universal EncodingDetector是一个很好的工具,网址是:http://chardet.feedparser.org/用起来很方便Usage[link] Basic usageThe easiest way to use the Universal Encoding Detector library iswith the detect function.[link]Example: Using the detect functio... « 阅读全文
Python自动化校内开心农场
登录成功,获取数据成功,翻地成功,播种成功,获取好友列表与好友详细信息成功,尚未解析返回数据的字段意义。#!/usr/bin/env python#encoding: utf-8import urllib,urllib2,cookielibimport httplib2import time,zlib,re,md5import cStringIO,gzipimport jsonclass Xiaonei: debug=True #创建Cookie def... « 阅读全文
Python抓网页内容
一、用urllib2/sgmllib包,将目标网页的所有URL列出。import urllib2from sgmllib import SGMLParser class URLLister(SGMLParser):def reset(self): SGMLParser.reset(self)self.urls = []def start_a(self, attrs): href = [v for k,... « 阅读全文
Unicode和纯文本间转换、输出与urllib乱码输出问题
需求:需要处理文本,里面包含非Ascii字符集的字符.讨论:unicode字符可以以多种形式编码,你可以选则自己需要的方式:unicodestring = u"Hello world" # Convert Unicode to plain Python string: "encode"utf8string = unicodestring.encode("utf-8")asciistring = unicodestring.encode("ascii") isostring = un... « 阅读全文
用python在校内自动发贴
首先声明:这只是学术研究用……使用这个东西的人要自重……恶心到别人的话我不负责…-_-|||写这个东西的目的……其实是为以后写一个多发机做准备……就是只用一个软件写blog,自动在你设定的所有的blog上发N的东东……于是,首先向校内开刀了……这个原理很简单……就是抓包后自己写包就行了……不过中途那... « 阅读全文

