
我想每天自動下載早晨版播客。我沒有任何蘋果產品。我下載並安裝了flareget,但不知道如何讓它做到這一點。我並沒有被那個工具束縛。我是 Firefox 的長期用戶,但目前正在測試 Chrome。
該程式的 URL 是: http://www.npr.org/programs/morning-edition/
RSS 位址是:http://www.npr.org/rss/rss.php?id=3
問題是 RSS 包含指向單一故事的網頁鏈接,而不是指向 mp3 的連結。
<rss xmlns:npr="http://www.npr.org/rss/" xmlns:nprml="http://api.npr.org/nprml" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<title>
Morning Edition : NPR
</title>
<link>
http://www.npr.org/templates/story/story.php?storyId=3
</link>
<description>
Morning Edition gives its audience news, analysis, commentary, and coverage of arts and sports. Stories are told through conversation as well as full reports. It's up-to-the-minute news that prepares listeners for the day ahead.
</description>
<language>en</language>
<copyright>Copyright 2015 NPR - For Personal Use Only</copyright>
<generator>NPR API RSS Generator 0.94</generator>
<lastBuildDate>Fri, 06 Nov 2015 12:45:00 -0500</lastBuildDate>
<image>
<url>http://media.npr.org/images/podcasts/primary/npr_generic_image_300.jpg?s=200</url>
<title>Morning Edition</title>
<link>http://www.npr.org/templates/story/story.php?storyId=3</link>
</image>
<item>
<title>Russian Airliner Crash Update</title>
<description>
The latest information on the Russian airliner that crashed in Egypt. All 224 people on board were killed.
</description>
<pubDate>Fri, 06 Nov 2015 12:45:00 -0500</pubDate>
<link>
http://www.npr.org/2015/11/06/455019224/russian-airliner-crash-update?utm_medium=RSS&utm_campaign=morningedition
</link>
<guid>
http://www.npr.org/2015/11/06/455019224/russian-airliner-crash-update?utm_medium=RSS&utm_campaign=morningedition
</guid>
<content:encoded>
<![CDATA[
<p>The latest information on the Russian airliner that crashed in Egypt. All 224 people on board were killed.</p>
]]>
</content:encoded>
<dc:creator>Corey Flintoff</dc:creator>
</item>
...
當我http://www.npr.org/2015/11/06/455019224/russian-airliner-crash-update?utm_medium=RSS&utm_campaign=morningedition
在瀏覽器中開啟時,頁面上有一個指向該故事的 mp3 檔案的連結:
http://pd.npr.org/anon.npr-mp3/npr/me/2015/11/20151106_me_egypt_plane_crash_probe_russia.mp3?dl=1
我可以看到我可以使用易於識別的模式,但無法弄清楚要使用哪些工具或如何讓它們執行我想要的操作。
每個故事的音訊檔案都以以下內容開頭:
http://pd.npr.org/anon.npr-mp3/npr/me/
然後添加該年份的資料夾
http://pd.npr.org/anon.npr-mp3/npr/me/2015
和一個月的一個
http://pd.npr.org/anon.npr-mp3/npr/me/2015/11
今天節目的所有 mp3 都是
yyyymmdd_me*.mp3
尾隨?dl=1
似乎沒有必要。
答案1
您需要編寫一個網路機器人來導航網站,直到您找到您想要下載的 .mp3 URL,然後準確下載這些 URL。
對於perl
,顯而易見的解決方案是使用libwww-perl包(又稱LWP
)。
對於python
,我會推薦機械化或者刮毛python 函式庫。
這兩個 python 庫都針對 Debian 和 Ubuntu 打包為 和python-mechanize
,python-scrapy
因此請安裝這些軟體包(並且不要遵循pip install
網站上的 或任何說明)
其他語言也有類似的函式庫。