Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/python
- from BeautifulSoup import BeautifulSoup
- import urllib2
- import time
- aschheim = 'http://www.autokinos-deutschland.de/programm/index-muenchen-aschheim.php?cPath=22'
- gravenbruch = 'http://www.autokinos-deutschland.de/programm/index-frankfurt-gravenbruch.php?cPath=24'
- essen = 'http://www.autokinos-deutschland.de/programm/indexessen.php?cPath=25'
- porz = 'http://www.autokinos-deutschland.de/programm/index-koeln-porz.php?cPath=26'
- kornwestheim = 'http://www.autokinos-deutschland.de/programm/index-stuttgart-kornwestheim.php?cPath=27'
- alle_filme = [[0 for x in range(3)] for x in range(20)]
- def unique_items(L):
- found = set()
- for item in L:
- if item[0] not in found:
- yield item
- found.add(item[0])
- def removeBlankRows(grid):
- return [list(row) for row in grid if any(row)]
- def getProgram(url):
- # 0 for x in range(cols_count) for x in range(rows_count)
- filme = [[0 for x in range(3)] for x in range(20)]
- i=0
- u=0
- kino=""
- if url == aschheim:
- kino = "[A]"
- elif url == gravenbruch:
- kino = "[G]"
- elif url == essen:
- kino = "[E]"
- elif url == porz:
- kino = "[P]"
- elif url == kornwestheim:
- kino = "[K]"
- response = urllib2.urlopen(url)
- html = response.read()
- soup = BeautifulSoup(html.decode('utf-8', 'ignore'), convertEntities=BeautifulSoup.HTML_ENTITIES)
- allg = soup.findAll("table", {"class" : "productListing"})
- einzelnfilm = allg[0].findAll("td", {"class" : "productListing-data"})
- for rows in einzelnfilm:
- startdatum = ""
- titel = einzelnfilm[i+1].find("div",{"class" : "FilmHeading1"})
- runtime_raw = einzelnfilm[i+1].findAll("tr")
- runtime = runtime_raw[2].findAll("td",{"class" : "productDesc"})
- filmtitel = titel.string.strip()
- startdatum += runtime[0].string.strip() + " "
- startdatum += runtime[1].string.strip()
- filme[u][0] = str(filmtitel)
- filme[u][1] = str(startdatum[4:])
- filme[u][2] = str(kino)
- i += 2
- u += 1
- if i == len(einzelnfilm):
- break
- return unique_items(filme)
- print ""
- print "Aktuelles Autokino Programm v0.1"
- print "[A] Aschheim"
- print "[G] Gravenbruch"
- print "[E] Essen"
- print "[P] Porz"
- print "[K] Kornwestheim"
- print ""
- alle_filme += getProgram(aschheim)
- alle_filme += getProgram(gravenbruch)
- alle_filme += getProgram(essen)
- alle_filme += getProgram(porz)
- alle_filme += getProgram(kornwestheim)
- alle_filme = removeBlankRows(alle_filme)
- alle_filme = sorted(alle_filme,key=lambda x:time.strptime(str(x[1]),"%d.%m."))
- alle_filme = unique_items(alle_filme)
- v = 1
- for row in alle_filme:
- print str(str(v) + " - " + row[1] + " - " + row[0] + " - " + row[2])
- v += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement