Advertisement
DeaD_EyE

Koran auf deutsch

Mar 23rd, 2018
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. import re
  2. from requests_html import HTMLSession
  3. # https://github.com/kennethreitz/requests-html
  4.  
  5.  
  6. def get_koran():
  7.     session = HTMLSession()
  8.     response = session.get('http://www.koran-auf-deutsch.de')
  9.     suren_links = [link for link in response.html.absolute_links if re.search(r'/\d{1,3}-', link)]
  10.     suren_links = sorted(suren_links, key=lambda link: int(re.search(r'/(\d{1,3})-', link).group(1)))
  11.     koran = []
  12.     for sure in suren_links:
  13.         print('Lade: {}'.format(sure))
  14.         koran.append(session.get(sure).html.find('.field-item', first=True).text)
  15.     koran_txt = '\n\n\n'.join(koran)
  16.     with open('Koran.txt', 'w') as fd:
  17.         fd.write(koran_txt)
  18.     return koran_txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement