VOA Special English MP3 Downloader

最近上下班开车挺无聊,听腻了各式音乐,打算利用上下班的时间学学英语,锻炼下生锈的耳朵,听听English MP3。以前一直比较喜欢VOA Special English的慢速版,虽然还是有一定的难度,但听起来多少能找到点感觉。今天突然心血来潮,google了下VOA的老家,很不幸,网页无法打开,第一直觉就是VOA被伟大的wall给挡住了。搜索了一下,果然如此……不过咱有SSH,怕啥?通过SSH果然可以正常访问,这也印证了前面的猜想。不过VOA的mp3貌似每天都出,一个一个点链接下载,实在是个体力活,人本来就有惰性,俺也不例外!于是,有了下面的想法……

咱IT民工,比较拿手的就是让电脑帮俺们去完成一些重复劳动,减轻体力负担,如果能让电脑自动帮俺下载mp3该多好!加之最近又在看python的东东,python很强大,几行代码就能完成复杂的工作。于是开始手痒,何不用python搞个下载器试试呢? 对了,有wall,怎么办?不怕!咱有VPS,哈哈哈!

开工!在VOA的页面,上找到RSS页面地址(RSS页面包含有最新发布的文章以及mp3下载链接),然后对RSS进行分析,写python脚本,调试,运行,效果还不错!最近发布文章的mp3被啪啪啪的拖到了VPS上。脚本十分简单:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/python
#VOA Special English MP3 Downloader.
#Written by Timothy 2010.3.10
import urllib,time;
from xml.dom import minidom
from os import system
url = "http://www1.voanews.com/templates/Articles.rss?sectionPath=/learningenglish/home"
link = urllib.urlopen(url)
#content=link.read()
rss = minidom.parse(link)
elements = rss.getElementsByTagName('media:content')
for element in elements:
if element.hasAttribute('type'):
print 'Now downloading:' + element.getAttribute('url')
system('wget -nc ' + element.getAttribute('url'))

运行效果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
timothy@vps:~$ ls
VOAEnglish.py
timothy@vps:~$ chmod +x VOAEnglish.py
timothy@vps:~$ ./VOAEnglish.py
Now downloading:http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-sin-2578-smoking-09mar10.Mp3
--2010-03-09 16:37:40-- http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-sin-2578-smoking-09mar10.Mp3
Resolving www.voanews.com... 72.247.217.25, 72.247.217.9
Connecting to www.voanews.com|72.247.217.25|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7765680 (7.4M) [audio/mpeg]
Saving to: `se-sin-2578-smoking-09mar10.Mp3'

100%[==========================>] 7,765,680 10.0M/s in 0.7s

2010-03-09 16:37:41 (10.0 MB/s) - `se-sin-2578-smoking-09mar10.Mp3' saved [7765680/7765680]

Now downloading:http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-ag-broccoli-9mar10.Mp3
--2010-03-09 16:37:41-- http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-ag-broccoli-9mar10.Mp3
Resolving www.voanews.com... 72.247.217.25, 72.247.217.9
Connecting to www.voanews.com|72.247.217.25|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1905683 (1.8M) [audio/mpeg]
Saving to: `se-ag-broccoli-9mar10.Mp3'

100%[==========================>] 1,905,683 9.44M/s in 0.2s

2010-03-09 16:37:41 (9.44 MB/s) - `se-ag-broccoli-9mar10.Mp3' saved [1905683/1905683]

Now downloading:http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-dev-int-womens-day-8mar10.Mp3
--2010-03-09 16:37:41-- http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-dev-int-womens-day-8mar10.Mp3
Resolving www.voanews.com... 72.247.217.25, 72.247.217.9
Connecting to www.voanews.com|72.247.217.25|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1907146 (1.8M) [audio/mpeg]
Saving to: `se-dev-int-womens-day-8mar10.Mp3'

100%[==========================>] 1,907,146 8.81M/s in 0.2s

2010-03-09 16:37:41 (8.81 MB/s) - `se-dev-int-womens-day-8mar10.Mp3' saved [1907146/1907146]

Now downloading:http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-tia-molly-brown-05mar10.Mp3
--2010-03-09 16:37:41-- http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-tia-molly-brown-05mar10.Mp3
Resolving www.voanews.com... 72.247.217.9, 72.247.217.25
Connecting to www.voanews.com|72.247.217.9|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7429432 (7.1M) [audio/mpeg]
Saving to: `se-tia-molly-brown-05mar10.Mp3'

100%[==========================>] 7,429,432 8.68M/s in 0.8s

2010-03-09 16:37:42 (8.68 MB/s) - `se-tia-molly-brown-05mar10.Mp3' saved [7429432/7429432]

Now downloading:http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-pia-todd-duncan-7mar10.Mp3
--2010-03-09 16:37:42-- http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-pia-todd-duncan-7mar10.Mp3
Resolving www.voanews.com... 72.247.217.9, 72.247.217.25
Connecting to www.voanews.com|72.247.217.9|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7470601 (7.1M) [audio/mpeg]
Saving to: `se-pia-todd-duncan-7mar10.Mp3'

100%[==========================>] 7,470,601 6.06M/s in 1.2s

2010-03-09 16:37:43 (6.06 MB/s) - `se-pia-todd-duncan-7mar10.Mp3' saved [7470601/7470601]

Now downloading:http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-itn-tea-party-6mar10.Mp3
--2010-03-09 16:37:43-- http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-itn-tea-party-6mar10.Mp3
Resolving www.voanews.com... 72.247.217.25, 72.247.217.9
Connecting to www.voanews.com|72.247.217.25|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2405145 (2.3M) [audio/mpeg]
Saving to: `se-itn-tea-party-6mar10.Mp3'

100%[==========================>] 2,405,145 3.98M/s in 0.6s

2010-03-09 16:37:44 (3.98 MB/s) - `se-itn-tea-party-6mar10.Mp3' saved [2405145/2405145]

Now downloading:http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-econ-corp-history-5mar10.Mp3
--2010-03-09 16:37:44-- http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-econ-corp-history-5mar10.Mp3
Resolving www.voanews.com... 72.247.217.9, 72.247.217.25
Connecting to www.voanews.com|72.247.217.9|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1940583 (1.9M) [audio/mpeg]
Saving to: `se-econ-corp-history-5mar10.Mp3'

100%[==========================>] 1,940,583 6.77M/s in 0.3s

2010-03-09 16:37:44 (6.77 MB/s) - `se-econ-corp-history-5mar10.Mp3' saved [1940583/1940583]

Now downloading:http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-mosaic-05mar10.Mp3
--2010-03-09 16:37:44-- http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-mosaic-05mar10.Mp3
Resolving www.voanews.com... 72.247.217.9, 72.247.217.25
Connecting to www.voanews.com|72.247.217.9|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7341034 (7.0M) [audio/mpeg]
Saving to: `se-mosaic-05mar10.Mp3'

100%[==========================>] 7,341,034 9.01M/s in 0.8s

2010-03-09 16:37:45 (9.01 MB/s) - `se-mosaic-05mar10.Mp3' saved [7341034/7341034]

timothy@vps:~$ ls
se-ag-broccoli-9mar10.Mp3 se-pia-todd-duncan-7mar10.Mp3
se-dev-int-womens-day-8mar10.Mp3 se-sin-2578-smoking-09mar10.Mp3
se-econ-corp-history-5mar10.Mp3 se-tia-molly-brown-05mar10.Mp3
se-itn-tea-party-6mar10.Mp3 VOAEnglish.py
se-mosaic-05mar10.Mp3
timothy@vps:~$

VPS和VOA都在米国,下载速度很快啊……几秒钟的功夫……

最后,再想办法把mp3统统拖回来本地即可。此脚本适合拥有VPS的、有兴趣的同学使用,后续会慢慢改进脚本。

支持原创技术分享,据说打赏我的人,都找到了女朋友!