Skip to content

Commit

Permalink
Merge pull request #480 from scholarly-python-package/develop
Browse files Browse the repository at this point in the history
(Pre-)Release v1.7.10 to enable conda build
  • Loading branch information
arunkannawadi authored Jan 4, 2023
2 parents 80aad41 + 434b25c commit 84f9e26
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
27 changes: 19 additions & 8 deletions scholarly/_proxy_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from selenium.common.exceptions import WebDriverException, UnexpectedAlertPresentException
from selenium.webdriver.firefox.options import Options as FirefoxOptions
from urllib.parse import urlparse
from fake_useragent import UserAgent
from contextlib import contextmanager
from deprecated import deprecated
try:
Expand All @@ -24,6 +23,13 @@
except ImportError:
stem = None

try:
from fake_useragent import UserAgent
FAKE_USERAGENT = True
except Exception:
FAKE_USERAGENT = False
DEFAULT_USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'

from .data_types import ProxyMode


Expand Down Expand Up @@ -454,13 +460,18 @@ def _new_session(self, **kwargs):
# self._session = httpx.Client()
self.got_403 = False

# Suppress the misleading traceback from UserAgent()
with self._suppress_logger('fake_useragent'):
_HEADERS = {
'accept-language': 'en-US,en',
'accept': 'text/html,application/xhtml+xml,application/xml',
'User-Agent': UserAgent().random,
}
if FAKE_USERAGENT:
# Suppress the misleading traceback from UserAgent()
with self._suppress_logger('fake_useragent'):
user_agent = UserAgent().random
else:
user_agent = DEFAULT_USER_AGENT

_HEADERS = {
'accept-language': 'en-US,en',
'accept': 'text/html,application/xhtml+xml,application/xml',
'User-Agent': user_agent,
}
# self._session.headers.update(_HEADERS)
init_kwargs.update(headers=_HEADERS)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='scholarly',
version='1.7.9',
version='1.7.10-alpha',
author='Steven A. Cholewiak, Panos Ipeirotis, Victor Silva, Arun Kannawadi',
author_email='[email protected], [email protected], [email protected], [email protected]',
description='Simple access to Google Scholar authors and citations',
Expand Down

0 comments on commit 84f9e26

Please sign in to comment.