私はこのコードを持っています:
import urllib
from bs4 import BeautifulSoup
f = open('log1.txt', 'w')
url ='http://www.brothersoft.com/tamil-font-513607.html'
pageUrl = urllib.urlopen(url)
soup = BeautifulSoup(pageUrl)
for a in soup.select("div.class1.coLeft a[href]"):
try:
suburl = ('http://www.brothersoft.com'+a['href']).encode('utf-8','replace')
f.write ('http://www.brothersoft.com'+a['href']+'\n')
except:
print 'cannot read'
f.write('cannot read:'+'http://www.brothersoft.com'+a['href']+'\n')
pass
content = urllib.urlopen(suburl)
soup = BeautifulSoup(content)
for a in soup.select("div.Sever1.coLeft a[href]"):
try:
suburl2 = ('http://www.brothersoft.com'+a['href']).encode('utf-8','replace')
f.write ('http://www.brothersoft.com'+a['href']+'\n')
except:
print 'cannot read'
f.write('cannot read:'+'http://www.brothersoft.com'+a['href']+'\n')
pass
content = urllib.urlopen(suburl2)
soup = BeautifulSoup(content)
for a in soup.select("span.p a[href]"):
try:
print (a['href']).encode('utf-8','replace')
f.write ('http://www.brothersoft.com'+a['href']+'\n')
except:
print 'cannot read'
f.write('cannot read:'+'http://www.brothersoft.com'+a['href']+'\n')
pass
f.close()
実行すると、次の結果が得られます。
http://www.brothersoft.com/d.php?soft_id=513607&url=http%3A%2F%2Ffiles.brotherso
ft.com%2Fphotograph_graphics%2Ffont_tools%2Fkeyman.exe&name=Tamil%20Font
http://ask.brothersoft.com/ask-a-question/?topic=1
http://ask.brothersoft.com/
http://www.brothersoft.com/d.php?soft_id=513607&url=http%3A%2F%2Fusfiles.brother
soft.com%2Fphotograph_graphics%2Ffont_tools%2Fkeyman.exe&name=Tamil%20Font
http://ask.brothersoft.com/ask-a-question/?topic=1
http://ask.brothersoft.com/
しかし、私が必要とするのは、次のような直接ダウンロード リンクだけです。