易截截图软件、单文件、免安装、纯绿色、仅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 读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 调用CAPICOM 读取 USB KEY数字证书

import win32com.client
store = win32com.client.Dispatch('CAPICOM.Store')
# 打开证书存储区
# 2 -> CAPICOM_CURRENT_USER_STORE
# 0 -> CAPICOM_STORE_OPEN_READ_ONLY
store.Open(2, "My", 0)
# 查找有效证书
# 12 -> CAPICOM_CERTIFICATE_FIND_KEY_USAGE
# 0x00000080 -> CAPICOM_DIGITAL_SIGNATU ......

安装Memcached For Win32 和 Memcached Python Client

    Memcached
是danga.com(运营LiveJournal的技术团队)开发的一套分布式内存对象缓存系统,用于在动态系统中减少数据库负载,提升性能。
    网上有很多讲到Memcached For Linux的安装教程,但是Memcached For Win32 and Python的就甚少,偶尔google找到一篇
比较相近的英文教程,觉得 ......

发布python应用程序

【windows+python3.1.2】
发布python应用程序是个很麻烦的事,因为<1>无法编译原生code<2>每个版本的字节码不同<3>如果直接上源码会损害自己的利益——等等
方法1——手动打包
怎么打包呢?一个python文件夹要二十多MB啊!
yes!我们就要清理无用的东西!
先写一个win.py文件: ......

python pop3 收邮件

def retrive_emails(pop3_server, user_name, passwd, server_port):
    #POP3
    pop_client = poplib.POP3(pop3_server, port=server_port)
    pop_client.user(user_name)
    pop_client.pass_(passwd)
   
    ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号