今天下不了榜单了,一开始我还以为是代码哪里写错了,检查到最后发现不是代码的问题,是谷歌改变页面布局了!
现在的热榜页没有Downlaod BottomBorder了,于是改用Related BottomBorder来判断添加到列表,而下
载ID则在Icon BottomBorder下依title寻找。下面是修改后的gmbox.py从热榜页面下载的html部分代码(经过编码转换
的,但为什么还有乱码呢?)
<table id="song_list" cellspacing="0" cellpadding="0"
class="SongList">
<!--freemusic_song_result_S40dbcfe0c610fa09-->
<tr id="rowS40dbcfe0c610fa09" class="SongItem BottomBorder"
onmouseover="_sl_onMouseOverSongItem("S40dbcfe0c610fa09");"
onmouseout="_sl_onMouseOutSongItem("S40dbcfe0c610fa09");">
<td class="Checkbox BottomBorder"><input type="checkbox"
name="item_toggle" id="S40dbcfe0c610fa09" value="S40dbcfe0c610fa09"
onclick="_sl_onClickCheckbox(this); return true;"></td>
<td class="number BottomBorder">1.</td>
<td class="Title BottomBorder"><a href="javascript:void(0)"
name="StreamingLink" oncontextmenu="return false;" onclick="return
_sl_onclickStreaming("/music/url?q\x3dhttp%3A%2F%
2Fwww.google.cn
%2Fmusic%2Ftop100%2Fplayer_iframe%3Fid%3DS40dbcfe0c610fa09%26type
%3Dsong%26autoplay%3Dtrue\x26resnum\x3d100\x26ct\x3dpl\x26cad\x3dchart
\x26cd\x3d1\x26ei\x3dWZ7xSei8GKPQswKe2s66AQ");">花蝴蝶</a>
</td>
<td class="Trend BottomBorder"><img alt="" src="/music/images/
trend_steady.gif"></td>
<td class="Artist BottomBorder">
<a href="/music/url?q=%2Fmusic%2Fartist%3Fid
%3DA24c74921880d4aa0&resnum=100&ct=nav&cad=chart&cd=1&ei=WZ7xSei8GKPQswKe2s66AQ"
style="white-space:nowrap;">蔡依林</a></td>
<td class="Related BottomBorder"><a href="/music/url?q=%2Fmusic
%2Fsong%3Fid
%3DS40dbcfe0c610fa09&ct=nav&cad=chart&ei=WZ7xSei8GKPQswKe2s66AQ"
oncontextmenu="return false;" id="SimilarityS40dbcfe0c610fa09" title="根
据音乐特质找到与花蝴蝶相似的歌曲">相似歌曲</a></td>
<td class="Icon BottomBorder">
<a href="javascript:void(0)" name="StreamingLink" title="试听"
oncontextmenu="return false;" onclick="return _sl_onclickStreaming
("/music/url?q\x3dhttp%3A%2F%
2Fwww.google.cn%2Fmusic
%2Ftop100%2Fplayer_iframe%3Fid%3DS40dbcfe0c610fa09%26type%3Dsong
%26autoplay%3Dtrue\x26resnum\x3d100\x26ct\x3dpl\x26cad\x3dchart\x26cd
\x3d1\x26ei\x3dWZ7xSei8GKPQswKe2s66AQ");"><img src="/music/images/
play_icon.gif" alt="试听"></a></td>
<td class="Icon BottomBorder"><a href="javascript:void(0)"
name="StreamingLink" title="加入播放列表" oncontextmenu="return false;"
onclick="return _sl_onclickStreaming("/music/url?q\x3dhttp%3A%2F
%
2Fwww.google.cn%2Fmusic%2Ftop100%2Fplayer_iframe%3Fid
%3DS40dbcfe0c610fa09%26type%3Dsong%26autoplay%3Dfalse\x26resnum
\x3d100\x26ct\x3dpl\x26cad\x3dchart\x26cd\x3d1\x26ei
\x3dWZ7xSei8GKPQswKe2s66AQ");"><img src="/music/images/
addsong_icon.gif" alt="加入播放列表"></a></td>
<td class="Icon BottomBorder"><a href="javascript:void(0)" title="下
载" oncontextmenu="return false;" onclick="window.open("/music/url?
q\x3dhttp%3A%2F%
2Fg.top100.cn%2F7872775%2Fhtml%2Fdownload.html%3Fid
%3DS40dbcfe0c610fa09\x26resnum\x3d100\x26ct\x3ddl\x26cad\x3dchart\x26cd
\x3d1\x26ei\x3dWZ7xSei8GKPQswKe2s66AQ", '',
"resizable\x3d0, status\x3d0, width\x3d650, height
\x3d350");
return false;"><img src="/music/images/download_icon.gif" alt="下
载"></a></td>
<td class="Icon BottomBorder"><a href="javascript:void(0)" title="歌
词" oncontextmenu="return false;" onclick="window.open("/music/url?
q\x3dhttp%3A%2F%
2Fg.top100.cn%2F7872775%2Fhtml%2Flyrics.html%3Fid
%3DS40dbcfe0c610fa09\x26resnum\x3d100\x26ct\x3dlr\x26cad\x3dchart\x26cd
\x3d1\x26ei\x3dWZ7xSei8GKPQswKe2s66AQ", '',
"resizable\x3d1, scrollbars\x3d0, status\x3d0, width\x3d450,
height\x3d510");
return false;"><img src="/music/images/lyrics_icon.gif" alt="歌词"></
a></td>
</tr>
</table>
从中看出下载页面url变了,
为
http://g.top100.cn/7872775/html/download.html?id=S40dbcfe0c610fa09
而在下载页面,下载链接藏于一个iframe里,我还不知道怎么找到具体url。
下面是源码:
<html>
<head>
<script type="text/javascript" src="../javascript/compiled/
static_page.js"></script>
<script type="text/javascript">
window.onload = function() {
_onloadDownloadPage();
}
window.onresize = function() {
_onWindowResize('download-iframe');
}
</script>
</head>
<body style="margin: 0px;">
<iframe id="download-iframe" src="" width="650" height="350"
frameborder="0" scrolling="no"/>
</body>
</html>