我想從http://www.youtube-mp3.org/下載幾首歌。我使用的是urllib2和BeautifulSoup。Python數據抓取
問題是,當我urllib2打開與我的視頻ID插入的網站,http://www.youtube-mp3.org/?c#v=lV7r8PiuecQ,我得到的網站,但他們很棘手,並加載後的初始頁面加載一些js ajax東西的信息。所以當我試圖抓取下載鏈接的URL時,從字面上看不在頁面上,因爲它沒有被加載。
任何人都知道我可能會觸發這個js加載器在我的Python腳本,或者什麼?
以下是我想要加載的內容之前的相關空html。
<div id="link_box" style="display:none">
<div id="link_box_title" style="font-weight:bold; text-decoration:underline">
</div>
<div class="row">
<div id="link_box_bb_code_title" style="font-weight:bold">
</div>
<input type="text" id="BBCodeLink" onclick="sAll(this)" />
</div>
<div class="row">
<div id="link_box_html_code_title" style="font-weight:bold">
</div>
<input type="text" id="HTMLLink" onclick="sAll(this)" />
</div>
<div class="row">
<div id="link_box_direct_code_title" style="font-weight:bold">
</div>
<input type="text" id="DirectLink" onclick="sAll(this)" />
</div>
</div>
<div id="v-ads">
</div>
<div id="dl_link">
</div>
<div id="progress">
</div>
<div id="loader">
<img src="ajax-loader-b.gif" alt="loading.." width="16" height="11" />
</div>
</div>
<div class="clear">
</div>
</div>
看起來我們需要http://youtube-mp3-scraper.org/:一個頁面,YouTube的擦傷,MP3,這反過來又刮的YouTube;) – phihag
嗯,因爲我在Mac上,也許我可以使用Automator來瀏覽youtube-mp3上的URL列表,並讓它們逐一下載到實際的瀏覽器中。我寧願留在Python中。 – Oliver
美麗的肥皂是處理鍵盤細菌的最佳蟒蛇庫。 – Profane