Oՠp d Z ddlZddlZddlZdgZ ej dd Z G d d Z G d d Z G d d Z dS )a% robotparser.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 http://www.robotstxt.org/norobots-rfc.txt NRobotFileParserRequestRatezrequests secondsc \ e Zd ZdZddZd Zd Zd Zd Zd Z d Z d Zd Zd Z d Zd ZdS )r zs This class provides a set of methods to read, parse and answer questions about a single robots.txt file. c g | _ g | _ d | _ d| _ d| _ | | d| _ d S )NFr )entriessitemaps default_entrydisallow_all allow_allset_urllast_checkedselfurls 9/opt/alt/python311/lib64/python3.11/urllib/robotparser.py__init__zRobotFileParser.__init__ sG !!S c | j S )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 mtimezRobotFileParser.mtime% s r c @ ddl }| | _ dS )zYSets the time the robots.txt file was last fetched to the current time. r N)timer )r r s r modifiedzRobotFileParser.modified. s# IIKKr c | || _ t j | dd \ | _ | _ dS )z,Sets the URL referring to a robots.txt file. N)r urllibparseurlparsehostpathr s r r zRobotFileParser.set_url6 s4 %|44S99!A#> 4999r c t j | j }| }| | d dS # t j j $ rK}|j dv rd| _ n)|j dk r|j dk rd| _ Y d}~dS Y d}~dS Y d}~dS Y d}~dS d}~ww xY w)z4Reads the robots.txt URL and feeds it to the parser.zutf-8)i i Ti i N) r requesturlopenr readr decode splitlineserror HTTPErrorcoder r )r frawerrs r r&