易截截图软件、单文件、免安装、纯绿色、仅160KB

Python 下载网页的几种方法

总结下,Python 下载网页的几种方法
1
 fd = urllib2.urlopen(url_link)
 data = fd.read()
 这是最简洁的一种,当然也是Get的方法
2
通过GET的方法
def GetHtmlSource(url):
    try:
   
        htmSource = ''
       
        req = urllib2.Request(url)
      
        fd = urllib2.urlopen(req,"")
       
        while 1:
            data = fd.read(1024)
            if not len(data):
                break
           
            htmSource += data
        fd.close()
 
        del fd
        del req
       
        htmSource = htmSource.decode('cp936')
        htmSource = formatStr(htmSource)
        
        return htmSource
       
    except socket.error, err:
       
        str_err =  "%s" % err
        return ""
3
 通过GET的方法
def GetHtmlSource_Get(htmurl):
    htmSource = ""
   
    try:
       
     


相关文档:

Python常用模块下载链接

Python http://www.python.org/download/ wxPython http://www.wxpython.org/download.php#binaries Vpython http://vpython.org/contents/download_windows.html Matplotlib http://sourceforge.net/projects/matplotlib/files/matplotlib/ PyGlet http://www.pyglet.org/download.html PyGame http://www.pyga ......

python 读http小记

conn = httplib.HTTPConnection(EPG_IP + ":" + HTTP_PORT)
url = FAV_URL_PARTH +"userid=" + USER_ID + FAV_DIR_MODIFY
param = '''<ps100request id="Favorite.Category.modify">
<categoryid>'''+categoryid+'''</categoryid>
<categoryname>'''+categoryname+'''</ ......

话说Python(一)

小白和小菜是大学同学,这不快要毕业了,俩人一合计,找个培训班学点东西,武装一下头脑,顺便解决就业问题。
“你们要报哪个班啊?”接待他们的年轻小姐热心地问道。
“你们这里哪个班最好?”小白不假思索地说,“当然是报最好的班啦。”
“我们公司的培训项目都很好”小姐笑 ......

python绘制螺旋线

#coding=utf-8
from math import sqrt,cos,sin
import Image, ImageDraw
class SpireShape(object):
    def __init__(self, draw):
        self.draw = draw
        self.line_width = 1
     & ......

windows & python & Emacs


设置Emacs的HOME,可以在scratch buffer中输入:(insert (getenv "HOME"))查看
下载python-mode.el
用Emacs打开python-mode.el然后M-x byte-compile-file编译python-mode.el为elc
C-h v查看load-path变量
在HOME/.emacs.d/init.el中添加(setq load-path (cons "D:\\emacs-23.1-bin-i386" load-path))
将py文件与pytho ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号