I am new to Python and am getting this error:
Traceback (most recent call last):
File \"/usr/local/bin/scrapy\", line 4, in
execute()
The error is pretty straightforward - the line starting with check_exists_sql
isn't indented properly. From the context of your code, I'd indent it and the following lines to match the line before it:
#open db connection
db = MySQLdb.connect("localhost","root","str0ng","TESTDB")
#prepare a cursor object using cursor() method
cursor = db.cursor()
#see if any links in the DB match the crawled link
check_exists_sql = "SELECT * FROM LINKS WHERE link = '%s' LIMIT 1" % item['link']
cursor.execute(check_exists_sql)
And keep indenting it until the for
loop ends (all the way through to and including items.append(item)
.