Edit File: robotparser.cpython-311.opt-1.pyc
� �����f�$����������������������������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 �����N�RobotFileParser�RequestRatezrequests secondsc��������������������\�����e�Zd�ZdZdd�Zd��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���)�entries�sitemaps� default_entry�disallow_all� allow_all�set_url�last_checked��self�urls��� �9/opt/alt/python311/lib64/python3.11/urllib/robotparser.py�__init__zRobotFileParser.__init__���sG����������� �!���!���������S�������������c�����������������������|�j���������S�)z�Returns 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#������ � ���� �I�I�K�K����r���c������������������|�����||�_���������t����������j�����������������������������|������������dd����������\��|�_��������|�_��������dS�)z,Sets the URL referring to a robots.txt file.��������N)r����urllib�parse�urlparse�host�pathr���s��� r���r ���zRobotFileParser.set_url6���s4���������%�|�4�4�S�9�9�!�A�#�>��� �4�9�9�9r���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����request�urlopenr����readr����decode� splitlines�error� HTTPError�coder���r���)r����f�raw�errs��� r���r&���zRobotFileParser.read;���s������� 9���&�&�t�x�0�0�A���&�&�(�(�C��J�J�s�z�z�'�*�*�5�5�7�7�8�8�8�8�8����|�%�� &�� &�� &��x�:�%�%�$(��!�!���S���S�X��^�^�!%����������!�������"�!�!�!�!�!�%3�^�^�^�^�^����� &���s����$A6��6C� .C�Cc������������������p�����d|j���������v�r|�j��������� ||�_��������d�S�d�S�|�j�����������������������������|�������������d�S��N�*)� useragentsr ���r����append)r����entrys��� r���� _add_entryzRobotFileParser._add_entryH���sM�������%�"�"�"��!�)�%*��"�"�"��*�)�� �L����&�&�&�&�&r���c������������������<����d}t������������������������}|�������������������������������������|D��]V}|sB|dk����rt������������������������}d}n+|dk����r%|����������������������|�������������t������������������������}d}|���������������������d������������}|dk����r |d|����������}|�����������������������������������}|s��|���������������������dd������������}t ����������|������������dk�����r�|d�������������������������������������������������������������������������������|d<���t����������j ��������� ��������������������|d��������������������������������������������������������|d<���|d���������dk����rM|dk����r#|����������������������|�������������t������������������������}|j�����������������������������|d����������������������d}��o|d���������dk����r8|dk����r0|j �����������������������������t����������|d���������d �������������������������d}���|d���������d k����r8|dk����r0|j �����������������������������t����������|d���������d�������������������������d}���|d���������dk����rP|dk����rH|d�������������������������������������������������������������������������������rt!����������|d���������������������|_��������d}��S|d���������d k����r�|dk����r�|d������������������������������d������������}t ����������|������������dk����r�|d�������������������������������������������������������������������������������rg|d�������������������������������������������������������������������������������r;t%����������t!����������|d���������������������t!����������|d���������������������������������|_��������d}��*|d���������dk����r |�j�����������������������������|d������������������������X|dk����r|����������������������|�������������dS�dS�)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���r��������#N�:z user-agent�disallowF�allowTzcrawl-delayzrequest-rate�/�sitemap)�Entryr���r5����find�strip�split�len�lowerr���r����unquoter2���r3���� rulelines�RuleLine�isdigit�int�delayr����req_rater ���)r����lines�stater4����line�i�numberss��� r���r���zRobotFileParser.parseQ���sJ������������� � ������7 2��7 2�D��� ��A�:�:�!�G�G�E��E�E��a�Z�Z��O�O�E�*�*�*�!�G�G�E��E�� � �#���A��A�v�v��B�Q�B�x���:�:�<�<�D��� ���:�:�c�1�%�%�D��4�y�y�A�~�~��q�'�-�-�/�/�/�/�1�1��Q�� �,�.�.�t�A�w�}�}���?�?��Q����7�l�*�*���z�z�����.�.�.� %�����$�+�+�D��G�4�4�4��E�E��!�W� �*�*���z�z���.�.�x��Q���/G�/G�H�H�H� !����!�W��'�'���z�z���.�.�x��Q���/F�/F�G�G�G� !����!�W� �-�-���z�z�� ��7�=�=�?�?�2�2�4�4��7�*-�d�1�g�,�,�E�K� !����!�W��.�.���z�z�"&�q�'�-�-��"4�"4����L�L�A�-�-�'�!�*�2B�2B�2D�2D�2L�2L�2N�2N�-� '�� � 0� 0� 2� 2� :� :� <� <��.�-8��W�Q�Z���#�g�VW�j�/�/�-Z�-Z�E�N� !����!�W� �)�)� ��M�(�(��a��1�1�1���A�:�:��O�O�E�"�"�"�"�"���:r���c����������������������|�j���������rdS�|�j��������rdS�|�j��������sdS�t����������j�����������������������������t����������j�����������������������������|������������������������}t����������j�����������������������������dd|j��������|j ��������|j ��������|j��������f������������}t����������j�����������������������������|������������}|sd}|�j ��������D�].}|���������������������|������������r|���������������������|������������c�S��/|�j��������r|�j�����������������������������|������������S�dS�)z=using the parsed robots.txt decide if useragent can fetch urlFTr���r<���)r���r���r���r���r���r ���rD���� urlunparser"����params�query�fragment�quoter���� applies_to� allowancer ���)r���� useragentr���� parsed_urlr4���s��� r���� can_fetchzRobotFileParser.can_fetch����s �������� ��5��>�� ��4� �� �� ��5���\�*�*�6�<�+?�+?��+D�+D�E�E� ��l�%�%�r�"�Z�_���j�.� �0C�'E��F��F���l� � ��%�%���� ��C��\�� ,�� ,�E���� �*�*�� ,����s�+�+�+�+�+� ,����� 5��%�/�/��4�4�4��tr���c�����������������������|�������������������������������������sd�S�|�j��������D�] }|���������������������|������������r |j��������c�S��!|�j��������r|�j��������j��������S�d�S��N)r���r���rV���rI���r ����r���rX���r4���s��� r����crawl_delayzRobotFileParser.crawl_delay����sm�������z�z�|�|�� ��4��\�� #�� #�E���� �*�*�� #��{�"�"�"� #���� ,��%�+�+��tr���c�����������������������|�������������������������������������sd�S�|�j��������D�] }|���������������������|������������r |j��������c�S��!|�j��������r|�j��������j��������S�d�S�r\���)r���r���rV���rJ���r ���r]���s��� r����request_ratezRobotFileParser.request_rate����sm�������z�z�|�|�� ��4��\�� &�� &�E���� �*�*�� &��~�%�%�%� &���� /��%�.�.��tr���c������������������"�����|�j���������sd�S�|�j���������S�r\���)r ���r���s��� r���� site_mapszRobotFileParser.site_maps����s�������}�� ��4��}�r���c�����������������������|�j���������}|�j���������||�j��������gz���}d���������������������t����������t����������|������������������������S�)Nz )r���r ����join�map�str)r���r���s��� r����__str__zRobotFileParser.__str__����s>�������,����)���!3� 4�4�G��{�{�3�s�G�,�,�-�-�-r���N)r���)�__name__� __module__�__qualname__�__doc__r���r���r���r ���r&���r5���r���rZ���r^���r`���rb���rg�����r���r���r���r������s������������������ �������!��!��!�(��(��(�?��?��?� 9��9��9�'��'��'�G#��G#��G#�R�����:��������������� .��.��.��.��.r���c��������������������$�����e�Zd�ZdZd��Zd��Zd��ZdS�)rF���zoA rule line is a single "Allow:" (allowance==True) or "Disallow:" (allowance==False) followed by a path.c������������������������|dk����r|sd}t�����������j�����������������������������t�����������j�����������������������������|������������������������}t�����������j�����������������������������|������������|�_��������||�_��������d�S�)Nr���T)r���r���rQ���r ���rU���r"���rW���)r���r"���rW���s��� r���r���zRuleLine.__init__����s[�������2�:�:�i�:��I��|�&�&�v�|�'<�'<�T�'B�'B�C�C���L�&�&�t�,�,�� �"����r���c������������������L�����|�j���������dk����p|���������������������|�j���������������������S�r0���)r"���� startswith)r����filenames��� r���rV���zRuleLine.applies_to����s$�������y�C��A�8�#6�#6�t�y�#A�#A�Ar���c������������������.�����|�j���������rdnddz���|�j��������z���S�)N�Allow�Disallowz: )rW���r"���r���s��� r���rg���zRuleLine.__str__����s�������>�9���z�T�A�D�I�M�Mr���N)rh���ri���rj���rk���r���rV���rg���rl���r���r���rF���rF�������sS��������������1��1�#��#��#�B��B��B�N��N��N��N��Nr���rF���c��������������������*�����e�Zd�ZdZd��Zd��Zd��Zd��ZdS�)r>���z?An entry has one or more user-agents and zero or more rulelinesc������������������>�����g�|�_���������g�|�_��������d�|�_��������d�|�_��������d�S�r\���)r2���rE���rI���rJ���r���s��� r���r���zEntry.__init__����s"�������������� ��� � � r���c������������������|����g�}|�j���������D�]}|���������������������d|�����������������|�j���������|���������������������d|�j������������������������|�j���������,|�j��������}|���������������������d|j����������d|j������������������������|���������������������t����������t����������|�j ���������������������������������d� ��������������������|������������S�)NzUser-agent: z Crawl-delay: zRequest-rate: r<���� )r2���r3���rI���rJ����requests�seconds�extendre���rf���rE���rd���)r����ret�agent�rates��� r���rg���z Entry.__str__����s����������_�� /�� /�E��J�J�-�e�-�-�.�.�.�.��:�!��J�J�3�t�z�3�3�4�4�4��=�$��=�D��J�J�F�� �F�F���F�F�G�G�G�� � �3�s�D�N�+�+�,�,�,��y�y��~�~�r���c�����������������������|����������������������d������������d��������������������������������������������}|�j��������D�]&}|dk����r�dS�|�����������������������������������}||v�r�dS��'dS�)z2check if this entry applies to the specified agentr<���r���r1���TF)rA���rC���r2���)r���rX���r}���s��� r���rV���zEntry.applies_to����sp��������O�O�C�(�(��+�1�1�3�3� ��_�� �� �E���|�|��t�t��K�K�M�M�E�� �!�!��t�t��"��ur���c������������������V�����|�j���������D�] }|���������������������|������������r |j��������c�S��!dS�)zZPreconditions: - our agent applies to this entry - filename is URL decodedT)rE���rV���rW���)r���rq���rM���s��� r���rW���zEntry.allowance ��sA��������N�� &�� &�D����x�(�(�� &��~�%�%�%� &��tr���N)rh���ri���rj���rk���r���rg���rV���rW���rl���r���r���r>���r>�������sV��������������I�I������ �� �� ��������������r���r>���)rk����collections�urllib.parser����urllib.request�__all__� namedtupler���r���rF���r>���rl���r���r����<module>r�������s������ �� �������������������������� ��$�k�$�]�4F�G�G��~.��~.��~.��~.��~.��~.��~.��~.�BN��N��N��N��N��N��N��N�$(��(��(��(��(��(��(��(��(��(r���