1.使用HTMLParser从百度MP3搜索结果中提取歌曲列表 """ 从百度MP3搜索结果中提取歌曲列表 方法是:使用数据结构---栈和级别来实现 1.将没有经过的tag全部入栈,经过的全部出栈 2.HTML语法错误处理使用级别来实现,栈顶的tag级别最低,如果高级别的tag要出栈,它会先将低级别的tag先出栈,这样可以避免遗漏的错误 3.对于错误的处理,先查找是否在栈内,如果没有则直接舍弃. 4.每次新的tag入栈,将data清空 5.针对特定的网页进行分析,百度MP3...
by jcodeer - Python文档中心 - 2007-11-03 23:43:20 阅读(1716) 回复(0)
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright (c) 2006 UbuntuChina # License: GPLv2 # Author: oneleaf # hack by ct import httplib import re import urllib import os import locale global m,topid global fsize fsize=1 #文件大小下限(M) allowext=['.mp3','.wma'] #允许的扩展名 topid='0' if topid=='0': topid='/list/newhits.html' #新歌100 elif topid=='1': ...
#!/usr/bin/python #BaiDu Blog Backuper v2 import urllib import string import re def Save2File(url,fn): print "Retrieving: ",url; print "Save as: ",fn try: URLFile=urllib.urlopen(url) except IOError: print "\nCan not retrieve ",url,"!\nThe connection cannot be made!\n" else: HTMLText=URLFile.read() URLFile.close() flist=fn.split("/") ...
google了一下,找到了一些用来从baidu下载mp3的软件,有win下的gui软件,也有linux下的shell脚本,还有python脚本, 但遗憾的是现在都已经无法用来下载mp3了,大概是因为百度mp3改版以后这些软件都没有修正吧,就顺手用python重写了一个,也算是练练手吧:) 下载 功能: 用来从百度下载mp3,可以单独下载指定的歌曲,也可以批量下载百度新歌Top100,脚本所接受的参数如下: Usage: /opt/bin/DownloadSong [OPTION] Download ...
新手做的,大家给点意见 仅适用于linux [code] #!/usr/bin/python #-*- coding: GB2312 -*- import re import os mp3topsonghtml=os.popen("wget 'http://list.mp3.baidu.com/topso/mp3topsong.html#top2' -O /dev/stdout").readlines() mp3samehtmllist=[] mp3=[] for i in mp3topsonghtml: b=re.compile('"http://mp3.baidu.com/m?.*\+.*"').search(i) if b: mp3samehtmllist.append(i[b.start():b.end()][1:-1...
#coding=gb2312 #抓取sina读书频道小说 import re import urllib as ub booklist = [40438,27128,27204,'浴火凤凰'] titlePre = "(.*?)" contentsPre = "(.*?)" start = booklist[1] end = booklist[2]+1 for i in range(start,end): url = 'http://vip.book.sina.com.cn/book/chapter_%d_%d.html' % (booklist[0],i) ufh = ub.urlopen(url) cont = ufh.read() title = re.findall(titlePre,cont) ...
使用google的coop创建了一个python.cn的搜索引擎 http://google.com/coop/cse?cx=009376466705745340527%3Acpxfleh5jbc 目前站点不多,我会加入一些个人的blog,还有那些没有的可以向我推荐,我把链接加进去
1.类A中的一个方法Fun1调用了Func2的方法是这样来写的: class A: def start(self): self.Fun1() def Fun1(): 2.创建一个类的对象然后调用这个类中的一个方法 写一个类 class A: hostlist={} log=Log() def getHost(self): try: m=model_host() lines=m.selectMuti()#调用这个类中的一个方法 except Exception,e: print str(e) self.hostli...
[code] class FooClass (object): """My very first class: FooClass""" version = 0.1 def __init__(self,nm="John Doe"): """constructor""" self.name = nm print 'Created a class instrance for', nm def showname(self): """display instance attribute and class name""" print 'Your name is ',self.name print 'My name is ',self.__class__.__name__ def showver(self): """display...
hello 大家好, 小弟是python新手, 最近遇到一个问题,查了很多地方不知道怎么解决, 上来请教下大家, 例如下面这个网页: http://stockhtm.finance.qq.com/hcenter/index.htm# 我想取得上面的股票信息,可是网页是动态的,上面的数据用 urllib 抓不回来, 不知道这种情况该怎么解决呢? 按理说, 数据已经在本地了。