From 1fa2b56d4d1da58f11b145a90d45eda29de0c768 Mon Sep 17 00:00:00 2001 From: t-tani <31282248+t-tani@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:24:55 +0900 Subject: [PATCH 1/2] Fix proxy settings. --- googlesearch/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/googlesearch/__init__.py b/googlesearch/__init__.py index 7efa821..54d73d8 100644 --- a/googlesearch/__init__.py +++ b/googlesearch/__init__.py @@ -45,10 +45,11 @@ def search(term, num_results=10, lang="en", proxy=None, advanced=False, sleep_in # Proxy proxies = None if proxy: - if proxy.startswith("https"): - proxies = {"https": proxy} - else: - proxies = {"http": proxy} + if proxy.startswith("http://") or proxy.startswith("https://"): + proxies = { + "https": proxy, + "http": proxy + } # Fetch start = 0 From 290d8f8806fd86711e9ec01e7a6c184711b79f16 Mon Sep 17 00:00:00 2001 From: t-tani <31282248+t-tani@users.noreply.github.com> Date: Fri, 19 Jul 2024 21:47:40 +0900 Subject: [PATCH 2/2] fix proxy settings --- googlesearch/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlesearch/__init__.py b/googlesearch/__init__.py index 2eec6fe..ab38640 100644 --- a/googlesearch/__init__.py +++ b/googlesearch/__init__.py @@ -40,7 +40,7 @@ def search(term, num_results=10, lang="en", proxy=None, advanced=False, sleep_in escaped_term = term.replace(" ", "+") # Proxy setup - proxies = {"https": proxy} if proxy and proxy.startswith("https") else {"http": proxy} if proxy else None + proxies = {"https": proxy, "http": proxy} if proxy and (proxy.startswith("https") or proxy.startswith("http")) else None start = 0 fetched_results = 0 # Keep track of the total fetched results