Skip to content

Instantly share code, notes, and snippets.

@ilkermanap
Created September 1, 2017 19:04
Show Gist options
  • Save ilkermanap/8cc4108130dcff30155c5c54d3d5f36d to your computer and use it in GitHub Desktop.
Save ilkermanap/8cc4108130dcff30155c5c54d3d5f36d to your computer and use it in GitHub Desktop.
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