]> git.phdru.name Git - bookmarks_db.git/commitdiff
Feat(bkmk_rurllib): Use proxy
authorOleg Broytman <phd@phdru.name>
Wed, 31 Jul 2024 16:22:58 +0000 (19:22 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 31 Jul 2024 22:48:38 +0000 (01:48 +0300)
Robots/bkmk_rurllib.py
Robots/bkmk_rurllib_py3.py

index 5b818a6a95ed377526e6d5aa5bd724c93b11ff11..19d9fc177c3f839be641e20cb5c4ad03b0e5d915 100644 (file)
@@ -85,6 +85,10 @@ urllib.ftpwrapper = myftpwrapper
 
 class robot_urllib(robot_base):
     def get(self, bookmark, url, accept_charset=False, use_proxy=False):
+        if use_proxy:
+            opener.proxies = {'http': self.proxy, 'https': self.proxy}
+        else:
+            opener.proxies = {}
         try:
             # Set fake referer to the base URL
             opener.addheaders[2] = ('Referer', url)
index b5c798ae840efb9a4b51d6f22b93b17ab7aed4e4..3928768f23fc990dff2412eeb7352b48e7614165 100644 (file)
@@ -86,6 +86,10 @@ urllib.request.ftpwrapper = myftpwrapper
 
 class robot_urllib_py3(robot_base):
     def get(self, bookmark, url, accept_charset=False, use_proxy=False):
+        if use_proxy:
+            opener.proxies = {'http': self.proxy, 'https': self.proxy}
+        else:
+            opener.proxies = {}
         try:
             # Set fake referer to the base URL
             opener.addheaders[2] = ('Referer', url)