我正在编写一个脚本从一个网站下载多个flac,我使用beautifulsoup获取flac链接并使用urlopen下载链接
我希望BS搜索以.flac结尾的链接(我不知道文件名,只知道扩展名EX:1是XXX.flac
,另一个是YYY.flac
)
flac文件的HTML在这里
<b><a class=location href="/soundtracks/index.php">Soundtracks</a><font class=location> » </font><a href="/soundtracks/highquality/index.php">High Quality Game
Soundtracks [FLAC]</a><font class=location> » </font><a href="/soundtracks/highquality/Metal_Gear_20th_Anniversary/72">Metal Gear 20th Anniversary</a><font class=location> » 01 Metal Gear 20 Years History -Past, Present, Future- Download</font></b><h1>Metal Gear 20th Anniversary Download Links:</h1><a style="font-size: 16px; font-weight:bold;" href="http://50.7.161.234/bks/94/245/Music/[029] MG 20th Anniversary [FLAC]/01 Metal Gear 20 Years History -Past, Present, Future-.flac">Metal Gear 20th Anniversary - 01 Metal Gear 20 Years History -Past, Present, Future-</a> <font face="Verdana" style="font-size: 16px;">Format: FLAC, Size: 76M</font><br> <font face="Verdana" style="font-size: 10px;"><b>Note: If the file starts playing in your browser window, try right-clicking and "Save Target As"</b></font><br>
我试图找到id.t = soup.find(id="flac")
,但没有得到任何相关的结果。我对此一无所知,我不知道有什么办法可以解决它
如何让BS搜索并找到文件链接,然后将该文件链接分配给一个变量?在
^{pr2}$
您的代码试图匹配链接到那些flac的锚标记中不存在的
id
属性。在而是使用正则表达式匹配以
.flac
结尾的href
:相关问题 更多 >
编程相关推荐