forked from egcodes/aristotle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getNotParsedSourceList.py
43 lines (34 loc) · 1.28 KB
/
getNotParsedSourceList.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
import sys
from datetime import datetime
from haberbusSources import createNewsSourceByPresent
from LogHandler import LogHandler
from ServerDatabaseHandler import ServerDatabaseHandler
from BeautifulSoup import BeautifulSoup
class Main:
def __init__(self):
self.logHandler = LogHandler("Main")
self.serverHandler = ServerDatabaseHandler()
self.run()
def run(self):
present = datetime.now()
self.yearMonth = str(present.strftime('%Y%m'))
print "[%s] Starting"%str(datetime.now())[:19]
sys.stdout.flush()
#===========================================================
# Kaynaklar olusturuluyor
#===========================================================
self.newsSources = createNewsSourceByPresent(present)
for data in self.newsSources.iteritems():
category = data[0]
sources = data[1]
for sourceList in sources:
startSource = datetime.now()
source = sourceList[0]
if not self.serverHandler.executeQuery("SELECT id FROM `links_%s` WHERE date BETWEEN DATE_SUB(NOW(), INTERVAL 3 DAY) AND NOW() and category='%s' and source='%s'"%(self.yearMonth, category, source)):
print category, " -> ", source
self.serverHandler.closeConnection()
print "Finished\n"
sys.stdout.flush()
if __name__ == "__main__":
main = Main()