0
<a href="/browse.php?cat=67" class="bb_a">2057: Discovery<br><span>(2057: Discovery channel)</span></a>
<a href="/browse.php?cat=36" class="bb_a">The 4400<br><span>(The 4400)</span></a>
<a href="/browse.php?cat=47" class="bb_a">Aqua<br><span>(Aquaman)</span></a>
如何解析上述字符串?Python美麗的湯,提供網址和名稱
我想在列表中的網址和名稱如下所示:
[["2057", "The 4400", "Aquaman"],
["/browse.php?cat=67", "/browse.php?cat=36", "/browse.php?cat=47"]]
使用下面的代碼,我已經可以解析網址
i = 0
for incident in soup.findAll('a'):
if ("browse.php?" in soup('a')[i]['href']):
print (soup('a')[i]['href'])
print soup('a')[i]['class']
i = i + 1;