我有此鏈接:如何獲得python beautifulsoup中的下一頁鏈接?
http://www.brothersoft.com/windows/categories.html
我想獲得的鏈接DIV中的項目。 例子:
http://www.brothersoft.com/windows/mp3_audio/midi_tools/
我曾嘗試這樣的代碼:
import urllib
from bs4 import BeautifulSoup
url = 'http://www.brothersoft.com/windows/categories.html'
pageHtml = urllib.urlopen(url).read()
soup = BeautifulSoup(pageHtml)
sAll = [div.find('a') for div in soup.findAll('div', attrs={'class':'brLeft'})]
for i in sAll:
print "http://www.brothersoft.com"+i['href']
但我只得到輸出:
http://www.brothersoft.com/windows/mp3_audio/
我怎樣才能得到我需要的輸出?
完美的工作,有什麼問題? – dorvak
輸出應該是http://www.brothersoft.com/windows/mp3_audio/midi_tools/ –