Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- from requests_html import HTMLSession
- # https://github.com/kennethreitz/requests-html
- def get_koran():
- session = HTMLSession()
- response = session.get('http://www.koran-auf-deutsch.de')
- suren_links = [link for link in response.html.absolute_links if re.search(r'/\d{1,3}-', link)]
- suren_links = sorted(suren_links, key=lambda link: int(re.search(r'/(\d{1,3})-', link).group(1)))
- koran = []
- for sure in suren_links:
- print('Lade: {}'.format(sure))
- koran.append(session.get(sure).html.find('.field-item', first=True).text)
- koran_txt = '\n\n\n'.join(koran)
- with open('Koran.txt', 'w') as fd:
- fd.write(koran_txt)
- return koran_txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement