-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0dfcf6
commit a2417b8
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# author = [email protected] | ||
# -*- coding: cp936 -*- | ||
# coding: cp936 | ||
|
||
import urllib2 | ||
import re | ||
import Ch1_download |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# author = [email protected] | ||
# -*- coding: cp936 -*- | ||
# coding: cp936 | ||
|
||
import itertools | ||
import re | ||
import Ch1_download | ||
|
||
def crawl_via_id_0(): | ||
for page in itertools.count(1): | ||
url = 'http://example.webscraping.com/places/default/view/-%d' % page | ||
html = Ch1_download.download_3(url) | ||
if html is None: | ||
break | ||
else: | ||
pass | ||
|
||
|
||
def crawl_via_id_1(): | ||
max_errors = 5 | ||
num_errors = 0 | ||
for page in itertools.count(1): | ||
url = 'http://example.webscraping.com/places/default/view/-%d' % page | ||
html = Ch1_download.download_3(url) | ||
if html is None: | ||
num_errors += 1 | ||
if num_errors == max_errors: | ||
break | ||
else: | ||
num_errors = 0 |