Browse code

Change user agent

Robert Cranston authored on 27/04/2022 13:33:50
Showing 1 changed files

... ...
@@ -135,6 +135,7 @@ REFPAGES_URL  = 'https://registry.khronos.org/OpenGL-Refpages/'
135 135
 REGISTRY_URL  = 'https://registry.khronos.org/OpenGL/'
136 136
 REFPAGES_GIT  = 'https://github.com/KhronosGroup/OpenGL-Refpages'
137 137
 XML_PATH      = 'xml/gl.xml'
138
+USER_AGENT    = 'Mozilla/5.0'
138 139
 REGEX         = r'\b(gl|GL_)[0-9A-Z][0-9A-Za-z_]+\b'
139 140
 EXCLUDE_DIRS  = ['.?*', '_*']
140 141
 EXCLUDE_FILES = ['README*', 'TODO*']
... ...
@@ -632,6 +633,9 @@ def refs_all(name):
632 633
 
633 634
 ## Main
634 635
 def main():
636
+    opener = urllib.request.build_opener()
637
+    opener.addheaders = [('User-Agent', USER_AGENT)]
638
+    urllib.request.install_opener(opener)
635 639
     args = docopt.docopt(__doc__)
636 640
     if args['xml']:           edit(xml          ())
637 641
     if args['xml-path']:      page(xml          ())