def toString(self):
     
     return NicksFunctions.lpad(str(self.year), '0', 4) + '-' + NicksFunctions.lpad(str(self.month), '0', 2) + '-' + NicksFunctions.lpad(str(self.day), '0', 2) + 'T' + NicksFunctions.lpad(str(self.hour), '0', 2) + ':' + NicksFunctions.lpad(str(self.minute), '0', 2) + ':' + NicksFunctions.lpad(str(self.second), '0', 2) + 'Z'
Exemple #2
0
lastTime = str(fTime.read())
fTime.close()

year = int(lastTime[0:lastTime.find('-')])
lastTime = lastTime[lastTime.find('-') + 1:]
month = int(lastTime[0:lastTime.find('-')])
lastTime = lastTime[lastTime.find('-') + 1:]
day = int(lastTime[0:lastTime.find('T')])
lastTime = lastTime[lastTime.find('T') + 1:]
hour = int(lastTime[0:lastTime.find(':')])
lastTime = lastTime[lastTime.find(':') + 1:]
minute = int(lastTime[0:lastTime.find(':')])
lastTime = lastTime[lastTime.find(':') + 1:]
second = int(lastTime[0:lastTime.find('Z')])

print str("Starting Search From: " + NicksFunctions.lpad(str(year), '0', 4) + '-' + NicksFunctions.lpad(str(month), '0', 2) + '-' + NicksFunctions.lpad(str(day), '0', 2) + 'T' + NicksFunctions.lpad(str(hour), '0', 2) + ':' + NicksFunctions.lpad(str(minute), '0', 2) + ':' + NicksFunctions.lpad(str(second), '0', 2) + 'Z') + '\n'

counter = 0

f = open('Test.csv', 'a')

# 2006,10,9,19,21,15

while(int(cmp(datetime.datetime.now(), runEndTime)) < 0) :
    
    timestamp = NicksFunctions.lpad(str(year), '0', 4) + '-' + NicksFunctions.lpad(str(month), '0', 2) + '-' + NicksFunctions.lpad(str(day), '0', 2) + 'T' + NicksFunctions.lpad(str(hour), '0', 2) + ':' + NicksFunctions.lpad(str(minute), '0', 2) + ':' + NicksFunctions.lpad(str(second), '0', 2) + 'Z'
    
    results = BeautifulSoup(urllib2.urlopen('http://api.thriftdb.com/api.hnsearch.com/items/_search?filter[fields][create_ts]=%22' + timestamp + '%22&pretty_print=true').read()).__str__().strip()
    results = results[results.find('"results":'):].strip()
    
    while(results.find('"item":') != -1) :
         
     elif(levelOfDetail == 2):
         
         targetTime.appendValues(0, 0, 0, 0, 1, 0)
         
     else:
         
         targetTime.appendValues(0, 0, 0, 0, 0, 1)
     
 else:
     
     counter += 1
     
     result.parseResultsForSubmissions()
     
     print NicksFunctions.lpad(str(counter), '0', 7) + ' : ' + NicksFunctions.lpad(str(result.getNumResults()), '0', 3) + ' : ' + result.getAddress()
     
     total += result.getNumResults()
     cyclicTotal += result.getNumResults()
     
     for hn in result.getSubmissions():
         
         dataFile.write(hn.toCSV())
     
     if(levelOfDetail == 0):
         
         curTime.appendValues(0, 0, 1, 0, 0, 0)
         targetTime = copy.copy(curTime)
         targetTime.appendValues(0, 0, 1, 0, 0, 0)
         
     elif(levelOfDetail == 1):