def findMode(monitor): """Controls the flow of finding articles and updating the database""" while(True): print "Enter key words to search for separated by a comma:" keyWords = raw_input() if (keyWords == ""): continue keyWords = [w.strip() for w in keyWords.split(",")] print "Searching for articles related to those keywords..." for source in SOURCES: links = monitor.scrapeURL(source, keyWords) print("Found %d article(s) on %s\n" % (len(links), source)) for link in links: title = link.string url = link.get("href") story = Story(title, url, keyWords, source) doc = story.getDocument() # Insert document into database monitor.addToDatabase(doc) # Print results to console print "ARTICLE TITLE: %s" % title print "URL: %s" % url break