12345678910111213141516171819202122232425262728 |
- #!/usr/bin/python3
- from bs4 import BeautifulSoup;
- import requests;
- import urllib;
- import re;
- def dosyayaYaz(url):
- source = requests.get(url);
- icerik = source.content;
- crawler = BeautifulSoup(icerik,"html.parser");
- dosya = open('/tmp/{}.txt'.format(crawler.html.head.title.string),'a');
- sozlerHam = crawler.find('div', {"class" : "reading"});
- sozler = str(sozlerHam);
- sarkiSozleri = re.sub('<.*?>', '\n', sozler);
- sarkiSozleri = re.sub('.*[;:]', '\n', sarkiSozleri);
- dosya.write(sarkiSozleri);
- return 1;
- def main():
- if htmlCek("https://www.rapsozler.com/rota-ultimatif-sarki-sozu/") == 1:
- print ("Dosyaya yazma başarılı.");
- else:
- print ("Dosyaya yazma başarısız.");
- main();
|