Skip to content

Commit f930b67

Browse files
committed
Added check for a starting point
1 parent 1912786 commit f930b67

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

PyCrawler.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,17 @@
1515
cursor.execute('CREATE TABLE IF NOT EXISTS crawl_index ( url VARCHAR(256) PRIMARY KEY, title VARCHAR(256), keywords VARCHAR(256) )')
1616
cursor.execute('CREATE TABLE IF NOT EXISTS queue ( url VARCHAR(256) PRIMARY KEY )')
1717
connection.commit()
18+
19+
if len(argv) < 2:
20+
print "No starting point! Checking existing queue"
21+
cursor.execute("SELECT * FROM queue LIMIT 1")
22+
c = cursor.fetchone()
23+
if c == None:
24+
sys.exit("ERROR: No start point! Exiting")
1825
try:
19-
cursor.execute("INSERT INTO queue VALUES ( (?) )", (sys.argv[1], ))
20-
connection.commit()
26+
if sys.argv[1]:
27+
cursor.execute("INSERT INTO queue VALUES ( (?) )", (sys.argv[1], ))
28+
connection.commit()
2129
except:
2230
pass
2331
keywordregex = re.compile('<meta\sname=["\']keywords["\']\scontent=["\'](.*?)["\']\s/>')

0 commit comments

Comments
 (0)