Пример #1
0
log = Logger()
link_file = Links()

log.write('Getting subreddit...')
cscareerquestions = reddit.get_subreddit('cscareerquestions')

if cscareerquestions:
  
  log.write('Getting comments...')
  comments = cscareerquestions.get_comments()
  
  log.write('Getting submissions...')
  submissions = cscareerquestions.get_hot(limit = 10)
  
  log.write('Loading history...')
  all_history = history.get_history()
  
  log.write('Looping through recent comments...')
  for comment in comments:
    id = comment.id
    log.write('Handling comment ' + str(id) + '...')
    if id not in all_history:
      log.write('Parsing new comment ' + str(id) + '...')
      body = comment.body
      links = LinkExtractor.extract_links(body)
      if len(links) > 0:
        for link in links:
          log.write('Storing new link ' + str(link) + '...')
          link_file.add(str(link))
        log.write('Adding ' + str(link) + ' to history...')
        history.add(id)