*j/ S r SSKrSSKrSSKrSSKrSSKrS/r\R " SS5 r " S S5 r
" S S5 r " S S
5 rS r
S rS
rS rS rg)zrobotparser.py
Copyright (C) 2000 Bastian Kleineidam
You can choose between two licenses when using this package:
1) GNU GPLv2
2) PSF license for Python 2.2
The robots.txt Exclusion Protocol is implemented as specified in
RFC 9309
NRobotFileParserRequestRatezrequests secondsc j \ rS rSrSrSS jrS rS rS rS r S r
S rS
rS r
S rS
rS rS rSrg)r zjThis class provides a set of methods to read, parse and answer
questions about a single robots.txt file.
c / U l 0 U l / U l S U l SU l SU l U R
U5 SU l g )NFr )entriesgroupssitemaps
default_entrydisallow_all allow_allset_urllast_checkedselfurls 9/opt/alt/python313/lib64/python3.13/urllib/robotparser.py__init__RobotFileParser.__init__ sB
!!S c U R $ )zReturns the time the robots.txt file was last fetched.
This is useful for long-running web spiders that need to
check for new robots.txt files periodically.
)r r s r mtimeRobotFileParser.mtime( s r c 6 SSK nUR 5 U l g)zISets the time the robots.txt file was last fetched to the
current time.
r N)timer )r r s r modifiedRobotFileParser.modified1 s
IIKr c n Xl [ R R U5 SS u U l U l g)z,Sets the URL referring to a robots.txt file. N)r urllibparseurlsplithostpathr s r r RobotFileParser.set_url9 s+ %||44S9!A> 49r c [ R R U R 5 nUR 5 nU R UR
SS5 R 5 5 g! [ R R aY nUR S; a SU l O'UR S: a UR S: a SU l UR 5 SnAgSnAff = f)z4Reads the robots.txt URL and feeds it to the parser.zutf-8surrogateescape)i i Ti i N)r" requesturlopenr readr# decode
splitlineserror HTTPErrorcoder r
close)r frawerrs r r, RobotFileParser.read> s
L&&txx0A &&(CJJszz'+<=HHJK ||%% xx:%$(!SSXX^!%IIKK s )A+ +C" ACC"c
U R R U5 UR HX nUR 5 nX R ; a XR U' M2 [ U R U U5 U R U' MZ g N)r append
useragentslowerr
merge_entries)r entryagents r
_add_entryRobotFileParser._add_entryL sc E"%%EKKMEKK'%*E"%24;;u3Eu%ME" &r c / nSn[ 5 nU R 5 U GH nUR S5 nUS: a USU nUR 5 nU( d M9 UR SS5 n[ U5 S:X d M\ US R 5 R
5 US' US R 5 US' US S:X aE US:X a U R U5 [ 5 nUS nUR R U5 SnM US S:X a7 US:w a. Sn UR R [ US S 5 5 GM! GM$ US S
:X a7 US:w a. Sn UR R [ US S5 5 GMa GMd US S:X aG US:w a> US R 5 R 5 ( a [ US 5 Ul SnGM GM US S
:X a US:w a US R S5 n[ U5 S:X au US R 5 R 5 ( aO US R 5 R 5 ( a) [! [ US 5 [ US 5 5 Ul SnGM` GMc US S:X d GMo U R$ R US 5 GM US:w a U R U5 gg! [ a GM f = f! [ a GM f = f)z|Parse the input lines from a robots.txt file.
We allow that a user-agent: line is not preceded by
one or more blank lines.
r #N:r z
user-agentdisallowFallowTzcrawl-delayzrequest-rate/sitemap)Entryr findstripsplitlenr; r? r: r9 rulelinesRuleLine
ValueErrorisdigitintdelayr req_rater
) r linesr stater= linei
product_tokennumberss r r# RobotFileParser.parseU s
D #AAvBQx::