Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9927beff
Commit
9927beff
authored
Feb 09, 2001
by
Eric S. Raymond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
String method conversion.
parent
cf92ff43
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
Lib/robotparser.py
Lib/robotparser.py
+8
-8
No files found.
Lib/robotparser.py
View file @
9927beff
...
...
@@ -9,7 +9,7 @@
The robots.txt Exclusion Protocol is implemented as specified in
http://info.webcrawler.com/mak/projects/robots/norobots-rfc.html
"""
import
re
,
string
,
urlparse
,
urllib
import
re
,
urlparse
,
urllib
__all__
=
[
"RobotFileParser"
]
...
...
@@ -71,7 +71,7 @@ class RobotFileParser:
entry
=
Entry
()
for
line
in
lines
:
line
=
string
.
strip
(
line
)
line
=
line
.
strip
(
)
linenumber
=
linenumber
+
1
if
not
line
:
if
state
==
1
:
...
...
@@ -85,16 +85,16 @@ class RobotFileParser:
entry
=
Entry
()
state
=
0
# remove optional comment and strip line
i
=
string
.
find
(
line
,
'#'
)
i
=
line
.
find
(
'#'
)
if
i
>=
0
:
line
=
line
[:
i
]
line
=
string
.
strip
(
line
)
line
=
line
.
strip
(
)
if
not
line
:
continue
line
=
string
.
split
(
line
,
':'
,
1
)
line
=
line
.
split
(
':'
,
1
)
if
len
(
line
)
==
2
:
line
[
0
]
=
string
.
lower
(
string
.
strip
(
line
[
0
])
)
line
[
1
]
=
string
.
strip
(
line
[
1
]
)
line
[
0
]
=
line
[
0
].
strip
().
lower
(
)
line
[
1
]
=
line
[
1
].
strip
(
)
if
line
[
0
]
==
"user-agent"
:
if
state
==
2
:
_debug
(
"line %d: warning: you should insert a blank"
...
...
@@ -136,7 +136,7 @@ class RobotFileParser:
return
1
# search for given user agent matches
# the first match counts
useragent
=
string
.
lower
(
useragent
)
useragent
=
useragent
.
lower
(
)
url
=
urllib
.
quote
(
urlparse
.
urlparse
(
url
)[
2
])
for
entry
in
self
.
entries
:
if
entry
.
applies_to
(
useragent
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment