# Test to see if the comic is already in the DB strips = db.query('select id from strips where comic_id=' + str(comic['id']) + ' and date = %s', today) if len(strips) > 0: print "Today's " + comic.name + " is already in the database, skipping." continue # Scrape the comic image from the comic website scraper = ComicScraper(comic) # Check for same image on page strips = db.query('select MAX(date), url from strips where comic_id=' + str(comic['id']) + ';') if len(strips) > 0: print "Checking for known image..." url = strips[0]['url'] if scraper.contentHasImage(url): print "Same image as last scrape, skipping." continue print "Scraping " + comic.name image = scraper.findComicImage() # If the scrape was successful pop it into the strips DB if image: sql = 'insert into strips (comic_id, date, url, alt, title, width) values ' sql += '(' + str(comic['id']) + ', %s, %s, %s, %s, ' + str(image['width']) + ');' db.execute(sql, today, image['src'], image['alt'], image['title']) print "Strip added to the DB!" else: print "No image found! Skipping..."
# # # # if ('rack-header.jpg') in image['src']: print 'header: BUST!\n' continue # Check for same image on page strips = db.query('select url from strips where comic_id=' + comic_id + ';') if len(strips) > 0: found = False print "Checking for known image..." for urlIn in strips: print urlIn if not found and scraper.contentHasImage(urlIn['url']): print "Same image as last scrape, skipping.\n" found = True continue if found: continue print "Scraping " + comic_name # If the scrape was successful pop it into the strips DB if image: wid = str(image['width']) src = str(image['src']) alt = str(image['alt']) tit = str(image['title']) sql = 'insert into strips (comic_id, date, url, alt, title, width) values '