mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
commit
67e8ede874
@ -14,4 +14,4 @@ from ._configs.chromium_options import ChromiumOptions
|
|||||||
from ._configs.session_options import SessionOptions
|
from ._configs.session_options import SessionOptions
|
||||||
|
|
||||||
__all__ = ['ChromiumPage', 'ChromiumOptions', 'SessionOptions', 'SessionPage', 'WebPage', '__version__']
|
__all__ = ['ChromiumPage', 'ChromiumOptions', 'SessionOptions', 'SessionPage', 'WebPage', '__version__']
|
||||||
__version__ = '4.0.5.3'
|
__version__ = '4.0.5.4'
|
||||||
|
@ -292,23 +292,25 @@ class SessionPage(BasePage):
|
|||||||
"""
|
"""
|
||||||
kwargs = CaseInsensitiveDict(kwargs)
|
kwargs = CaseInsensitiveDict(kwargs)
|
||||||
if 'headers' not in kwargs:
|
if 'headers' not in kwargs:
|
||||||
kwargs['headers'] = {}
|
kwargs['headers'] = CaseInsensitiveDict()
|
||||||
else:
|
else:
|
||||||
kwargs['headers'] = CaseInsensitiveDict(format_headers(kwargs['headers']))
|
kwargs['headers'] = CaseInsensitiveDict(format_headers(kwargs['headers']))
|
||||||
|
|
||||||
# 设置referer和host值
|
# 设置referer和host值
|
||||||
parsed_url = urlparse(url)
|
parsed_url = urlparse(url)
|
||||||
hostname = parsed_url.hostname
|
hostname = parsed_url.netloc
|
||||||
scheme = parsed_url.scheme
|
scheme = parsed_url.scheme
|
||||||
if not check_headers(kwargs['headers'], self._headers, 'Referer'):
|
if not check_headers(kwargs['headers'], self._headers, 'Referer'):
|
||||||
kwargs['headers']['Referer'] = self.url if self.url else f'{scheme}://{hostname}'
|
kwargs['headers']['Referer'] = self.url if self.url else f'{scheme}://{hostname}'
|
||||||
if 'Host' not in kwargs['headers']:
|
if not check_headers(kwargs['headers'], self._headers, 'Host'):
|
||||||
kwargs['headers']['Host'] = hostname
|
kwargs['headers']['Host'] = hostname
|
||||||
|
|
||||||
if not check_headers(kwargs, self._headers, 'timeout'):
|
if not check_headers(kwargs, self._headers, 'timeout'):
|
||||||
kwargs['timeout'] = self.timeout
|
kwargs['timeout'] = self.timeout
|
||||||
|
|
||||||
kwargs['headers'] = {**self._headers, **kwargs['headers']}
|
h = CaseInsensitiveDict(self._headers)
|
||||||
|
for k, v in kwargs['headers'].items():
|
||||||
|
h[k] = v
|
||||||
|
kwargs['headers'] = h
|
||||||
|
|
||||||
r = err = None
|
r = err = None
|
||||||
retry = retry if retry is not None else self.retry_times
|
retry = retry if retry is not None else self.retry_times
|
||||||
|
Loading…
x
Reference in New Issue
Block a user