Created
September 1, 2017 19:04
-
-
Save ilkermanap/8cc4108130dcff30155c5c54d3d5f36d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.kocaeli.edu.tr | |
http://www.hurriyet.com.tr | |
http://www.google.se | |
http://www.yahoo.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup as bs | |
import os | |
import time | |
class Sayfa: | |
def __init__(self, icerik): | |
self.icerik = icerik | |
self.tarih = None | |
self.soup = bs(self.icerik, "lxml") | |
self.li = self.soup.find_all("a") | |
self.title = self.soup.title.string | |
self.span = self.soup.find_all("span") | |
class LokalSayfa(Sayfa): | |
def __init__(self, fname): | |
self.dosya = fname | |
icerik = open(fname,"r").read() | |
Sayfa.__init__(self, icerik) | |
self.tarih = time.gmtime(os.stat(fname).st_ctime) | |
def guncelle(self): | |
icerik = open(self.dosya,"r").read() | |
Sayfa.__init__(self, icerik) | |
self.tarih = time.gmtime(os.stat(self.dosya).st_ctime) | |
class UzakSayfa(Sayfa): | |
def __init__(self, url): | |
self.url = url | |
r = requests.get(url) | |
icerik = r.text | |
Sayfa.__init__(self, icerik) | |
self.tarih = time.localtime() | |
def guncelle(self): | |
r = requests.get(self.url) | |
icerik = r.text | |
Sayfa.__init__(self, icerik) | |
self.tarih = time.localtime() | |
links = open("links.txt","r").readlines() | |
for link in links: | |
link = link.strip() | |
x = UzakSayfa(link) | |
print( link, x.title) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment