python定时器爬取豆瓣音乐Top榜歌名,python定时器,作者:vpoet日期:大
python定时器爬取豆瓣音乐Top榜歌名,python定时器,作者:vpoet日期:大
作者:vpoet
日期:大约在夏季
注:这些小demo都是前段时间为了学python写的,现在贴出来纯粹是为了和大家分享一下
#coding=utf-8 import urllib import urllib2 import re import time def SaveTop20Music(currtime): rex=r'<a href="javascript:;">(.*?)</a>'; url = 'http://music.douban.com/chart'; Response = urllib2.urlopen(url); Html=Response.read(); listsofsong = re.findall(rex, Html); print len(listsofsong); f=open('%s.txt' % currtime,'w'); x=1; for line in listsofsong: f.write('top'+str(x)+':'+line); f.write('\n'); x=x+1; f.flush(); f.close(); print currtime+'.txt'+'\t\t'+'SaveOver' def timer(n): while True: currtime = time.strftime("Savetime_%H-%M-%S", time.localtime()) print currtime SaveTop20Music(currtime) time.sleep(n) if __name__ == "__main__": timer(5)
相关内容
- Python创建Windows 服务,python创建windows,Python 写wind
- urllib2下载文件,,#!/usr/bin/p
- 画折线图的程序,画折线图程序,#_*_coding:u
- python 去除html标签的代码,python去除html标签,#! /usr/bin
- python模拟按键,自动翻页看u17漫画,pythonu17,#-*- coding
- 地月关系统模拟图示,月关模拟图示,#!/usr/bin/e
- 蒙提霍尔问题,蒙提霍尔,#coding: utf
- python通过pil生成缩略图的简单代码,pythonpil,python通过
- python抓取图片示例,,#!/usr/bin/p
- 文件结构扁平化,结构扁平化,def flatten(
评论关闭