BeautifulSoup, чтобы очистить адрес
Я использую код в дальнем конце, чтобы получитьссылка на сайтиИмя Масджид, Однако я хотел бы также получитьнаименование а такжеадрес улицы, Пожалуйста, помогите, я застрял.
В настоящее время я получаю следующее
Ссылка на сайт:
<a href="http://www.salatomatic.com/d/Tempe+5313+Masjid-Al-Hijrah">
</a>
Masjid Al-Hijrah
Denomination: Sunni (Traditional)
<br>45 Station Street (Sydney)
Приведенный ниже код очищает следующее
<a href="http://www.salatomatic.com/d/Tempe+5313+Masjid-Al-Hijrah"><img src="http://www.halalfire.com/images/en/photo_small.jpg" alt="Masjid Al-Hijrah" title="Masjid Al-Hijrah" border="0" width="48" height="36"></a><img src="http://www.salatomatic.com/images/spacer.gif" width="10" border="0"><a href="http://www.salatomatic.com/d/Tempe+5313+Masjid-Al-Hijrah">Masjid Al-Hijrah</a> Denomination: Sunni (Traditional)<br>45 Station Street (Sydney)
КОД:
from bs4 import BeautifulSoup
import urllib2
url1 = "http://www.salatomatic.com/c/Sydney+168"
content1 = urllib2.urlopen(url1).read()
soup = BeautifulSoup(content1)
results = soup.findAll("div", {"class" : "subtitleLink"})
for result in results :
br = result.find('b')
a = result.find('a')
currenturl = a.get('href')
if not currenturl.startswith("http"):
currenturl = "http://www.salatomatic.com" + currenturl
print currenturl
elif currenturl.startswith("http"):
print a.get('href')
pos = br.get_text()
print pos