mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
在requests的源码删除\x08(退格)和\x0D(换行)字符,以修改私有变量的方式
This commit is contained in:
parent
2e354e8881
commit
fe9b308562
@ -18,6 +18,7 @@ from requests_html import HTMLSession, HTMLResponse
|
|||||||
from .common import get_loc_from_str, translate_loc_to_xpath, avoid_duplicate_name
|
from .common import get_loc_from_str, translate_loc_to_xpath, avoid_duplicate_name
|
||||||
from .config import OptionsManager
|
from .config import OptionsManager
|
||||||
from .session_element import SessionElement, execute_session_find
|
from .session_element import SessionElement, execute_session_find
|
||||||
|
from html import unescape
|
||||||
|
|
||||||
|
|
||||||
class SessionPage(object):
|
class SessionPage(object):
|
||||||
@ -62,6 +63,7 @@ class SessionPage(object):
|
|||||||
@property
|
@property
|
||||||
def html(self) -> str:
|
def html(self) -> str:
|
||||||
"""获取元素innerHTML,如未指定元素则获取所有源代码"""
|
"""获取元素innerHTML,如未指定元素则获取所有源代码"""
|
||||||
|
# return unescape(self.response.html.raw_html.replace(b'\x08', b'').decode()).replace('\xa0', ' ')
|
||||||
return self.response.html.html
|
return self.response.html.html
|
||||||
|
|
||||||
def ele(self, loc_or_ele: Union[tuple, str, SessionElement], mode: str = None, show_errmsg: bool = False) \
|
def ele(self, loc_or_ele: Union[tuple, str, SessionElement], mode: str = None, show_errmsg: bool = False) \
|
||||||
@ -229,6 +231,7 @@ class SessionPage(object):
|
|||||||
charset = 'utf-8'
|
charset = 'utf-8'
|
||||||
else:
|
else:
|
||||||
charset = headers['Content-Type'].split('=')[1]
|
charset = headers['Content-Type'].split('=')[1]
|
||||||
|
r._content = r.content.replace(b'\x08', b'').replace(b'\x0d', b'') # TODO: 待测试
|
||||||
r.encoding = charset
|
r.encoding = charset
|
||||||
return_value = r
|
return_value = r
|
||||||
return return_value
|
return return_value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user