Skip to content

Commit 1912786

Browse files
committed
Switched continue statements not in the loop to pass statements which were a result of switching the body of the program to a function.
1 parent 4accdac commit 1912786

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

‎PyCrawler.py‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@
2626
classthreader ( threading.Thread ):
2727
defrun(self):
2828
while1:
29-
crawl()
29+
try:
30+
cursor.execute("SELECT * FROM queue LIMIT 1")
31+
crawling=cursor.fetchone()
32+
crawling=crawling[0]
33+
cursor.execute("DELETE FROM queue WHERE url = (?)", (crawling, ))
34+
connection.commit()
35+
printcrawling
36+
exceptKeyError:
37+
raiseStopIteration
38+
self.crawl(crawling)
3039

31-
defcrawl():
32-
try:
33-
cursor.execute("SELECT * FROM queue LIMIT 1")
34-
crawling=cursor.fetchone()
35-
crawling=crawling[0]
36-
cursor.execute("DELETE FROM queue WHERE url = (?)", (crawling, ))
37-
connection.commit()
38-
printcrawling
39-
exceptKeyError:
40-
raiseStopIteration
40+
defcrawl(self, crawling):
4141
url=urlparse.urlparse(crawling)
4242
try:
4343
crawled.append(crawling)
@@ -46,7 +46,7 @@ def crawl():
4646
try:
4747
response=urllib2.urlopen(crawling)
4848
except:
49-
continue
49+
return
5050
msg=response.read()
5151
startPos=msg.find('<title>')
5252
ifstartPos!=-1:
@@ -79,6 +79,6 @@ def crawl():
7979
cursor.execute("INSERT INTO crawl_index VALUES( (?), (?), (?) )", (crawling, title, keywordlist))
8080
connection.commit()
8181
except:
82-
continue
82+
pass
8383
if__name__=='__main__':
8484
threader().run()

0 commit comments

Comments
(0)