mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
session的网址会自动去除http://和https://
This commit is contained in:
parent
94a544b731
commit
fb580fda00
@ -110,14 +110,23 @@ class SessionOptions(object):
|
|||||||
self._proxies = {}
|
self._proxies = {}
|
||||||
return self._proxies
|
return self._proxies
|
||||||
|
|
||||||
def set_proxies(self, http, https=None):
|
def set_proxies(self, http=None, https=None):
|
||||||
"""设置proxies参数
|
"""设置proxies参数
|
||||||
:param http: http代理地址
|
:param http: http代理地址
|
||||||
:param https: https代理地址
|
:param https: https代理地址
|
||||||
:return: 返回当前对象
|
:return: 返回当前对象
|
||||||
"""
|
"""
|
||||||
proxies = None if http == https is None else {'http': http, 'https': https or http}
|
if isinstance(http, str):
|
||||||
self._sets('proxies', proxies)
|
if http.startswith('http://'):
|
||||||
|
http = http[7:]
|
||||||
|
elif http.startswith('https://'):
|
||||||
|
http = http[8:]
|
||||||
|
if isinstance(https, str):
|
||||||
|
if https.startswith('http://'):
|
||||||
|
https = https[7:]
|
||||||
|
elif http.startswith('https://'):
|
||||||
|
https = https[8:]
|
||||||
|
self._sets('proxies', {'http': http, 'https': https})
|
||||||
return self
|
return self
|
||||||
|
|
||||||
# ===========须独立处理的项结束============
|
# ===========须独立处理的项结束============
|
||||||
|
@ -366,14 +366,23 @@ class SessionPageSetter(object):
|
|||||||
"""
|
"""
|
||||||
self._page.session.headers['user-agent'] = ua
|
self._page.session.headers['user-agent'] = ua
|
||||||
|
|
||||||
def proxies(self, http, https=None):
|
def proxies(self, http=None, https=None):
|
||||||
"""设置proxies参数
|
"""设置proxies参数
|
||||||
:param http: http代理地址
|
:param http: http代理地址
|
||||||
:param https: https代理地址
|
:param https: https代理地址
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
proxies = None if http == https is None else {'http': http, 'https': https or http}
|
if isinstance(http, str):
|
||||||
self._page.session.proxies = proxies
|
if http.startswith('http://'):
|
||||||
|
http = http[7:]
|
||||||
|
elif http.startswith('https://'):
|
||||||
|
http = http[8:]
|
||||||
|
if isinstance(https, str):
|
||||||
|
if https.startswith('http://'):
|
||||||
|
https = https[7:]
|
||||||
|
elif https.startswith('https://'):
|
||||||
|
https = https[8:]
|
||||||
|
self._page.session.proxies = {'http': http, 'https': https}
|
||||||
|
|
||||||
def auth(self, auth):
|
def auth(self, auth):
|
||||||
"""设置认证元组或对象
|
"""设置认证元组或对象
|
||||||
|
@ -177,7 +177,7 @@ class SessionPageSetter(object):
|
|||||||
|
|
||||||
def user_agent(self, ua: str) -> None: ...
|
def user_agent(self, ua: str) -> None: ...
|
||||||
|
|
||||||
def proxies(self, http, https=None) -> None: ...
|
def proxies(self, http: str = None, https: str = None) -> None: ...
|
||||||
|
|
||||||
def auth(self, auth: Union[Tuple[str, str], HTTPBasicAuth, None]) -> None: ...
|
def auth(self, auth: Union[Tuple[str, str], HTTPBasicAuth, None]) -> None: ...
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user