From 6347c7847aabe704353442b60b38cb3d7cef63b7 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 31 Jul 2024 19:22:58 +0300 Subject: [PATCH] Feat(bkmk_rurllib): Use proxy --- Robots/bkmk_rurllib.py | 4 ++++ Robots/bkmk_rurllib_py3.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Robots/bkmk_rurllib.py b/Robots/bkmk_rurllib.py index 5b818a6..19d9fc1 100644 --- a/Robots/bkmk_rurllib.py +++ b/Robots/bkmk_rurllib.py @@ -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) diff --git a/Robots/bkmk_rurllib_py3.py b/Robots/bkmk_rurllib_py3.py index b5c798a..3928768 100644 --- a/Robots/bkmk_rurllib_py3.py +++ b/Robots/bkmk_rurllib_py3.py @@ -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) -- 2.39.5