Ich versuche, einige Box Office Mojo Seiten für Worldwide Kasse Bruttozahl mit Schönem Soup.My Code unten zu kratzen wird die Domestic Zahlen ganz gut greifen, wird nicht funktionieren wenn ich in "Weltweit" für "Inlandsgesamtbrutto" subsummiere. Vielleicht, weil "Worldwide" mehr als einmal auf der Seite angezeigt wird.Schöne Suppe schabt für „Worldwide“
Hilfe bei der Reparatur? Ich werde den Quellcode für die beiden Teile auch hinter mir lassen. Vielen Dank!
Quellcode unter
<center><table border="0" border="0" cellspacing="1" cellpadding="4" bgcolor="#dcdcdc" width="95%"><tr bgcolor="#ffffff"><td align="center" colspan="2"><font size="4">Domestic Total Gross: <b>$172,825,435</b></font></td></tr><tr bgcolor="#ffffff"><td valign="top">Distributor: <b><a href="/studio/chart/?studio=mgm.htm">MGM</a></b></td><td valign="top">Release Date: <b><nobr><a href="/schedule/?view=bydate&release=theatrical&date=1988-12-16&p=.htm">December 16, 1988</a></nobr></b></td></tr><tr bgcolor="#ffffff"><td valign="top">Genre: <b>Drama</b></td><td valign="top">Runtime: <b>2 hrs. 13 min.</b></td></tr><tr bgcolor="#ffffff"><td valign="top">MPAA Rating: <b>R</b></td><td valign="top">Production Budget: <b>$25 million</b></td></tr></table> </td>
... überspringen ...
<tr>
<td width="40%">= <b>Worldwide:</b></td>
<td width="35%" align="right"> <b>$354,825,435</b></td>
<td width="25%"> </td>
</tr>
Python-Code unter
BOG_titles = ['=RainMan.htm']
def get_movie_value(soup, field_name):
obj = soup.find(text = re.compile(field_name))
if not obj:
return "Nothing"
next_sibling = obj.findNextSibling()
if next_sibling:
return next_sibling.text
else:
return "Still Nothing"
BOG_data = []
for x in BOG_titles:
y = 'http://www.boxofficemojo.com/movies/?id' + x
page = urllib2.urlopen(y)
soup = BeautifulSoup(page)
m = get_movie_value(soup, "Worldwide")
title_string = soup.find('title').text
title = title_string.split('(')[0].strip()
BOG_data.append([title,m])
Welche genaue Informationen wünschen Sie? –
Ich möchte weltweite Kinobruttozahlen für eine Vielzahl von Filmen, wie auf Box Mojo Seiten aufgelistet. – Kees