Advertisement
DeaD_EyE

koka in rammstein songtexten

Jun 1st, 2019
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. import requests_html
  2.  
  3.  
  4. def get_songtexte(band='rammstein_songtexte.html', ending='_rammstein.html'):
  5.     with requests_html.HTMLSession() as session:
  6.         base = 'http://www.songtextemania.com/'
  7.         index = session.get(base + band)
  8.         links = [base + l for l in index.html.links if l.endswith(ending)]
  9.         songs = []
  10.         css_selector = 'html body div#container div#main div#content div.col-left-lyrics div.lyrics-body'
  11.         for link in links:
  12.             songpage = session.get(link)
  13.             for song in songpage.html.find(css_selector):
  14.                 songs.append((link, song.text))
  15.         return songs
  16.  
  17.        
  18. def find(word, songs):
  19.     for url, song in songs:
  20.         if word.lower() in song.lower():
  21.             print(url, song, sep='\n\n')
  22.             print('='*20)
  23.  
  24.  
  25. songs = get_songtexte()
  26. find('koka', songs)
  27.  
  28. # http://www.songtextemania.com//benzin_songtext_rammstein.html
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement