Pass str object to BeautifulSoup, not bytes. closes #56
This commit is contained in:
parent
113a3b6405
commit
0be9046669
1 changed files with 3 additions and 4 deletions
|
@ -64,18 +64,17 @@ def request(url: str, method: str="GET", get_params: dict={},
|
|||
signal.signal(signal.SIGALRM, signal.SIG_IGN)
|
||||
|
||||
response_headers = utils.CaseInsensitiveDict(dict(response.headers))
|
||||
|
||||
data = response_content.decode(response.encoding or fallback_encoding)
|
||||
content_type = response.headers["Content-Type"].split(";", 1)[0]
|
||||
|
||||
if soup:
|
||||
if content_type in SOUP_CONTENT_TYPES:
|
||||
soup = bs4.BeautifulSoup(response_content, parser)
|
||||
soup = bs4.BeautifulSoup(data, parser)
|
||||
return Response(response.status_code, soup, response_headers)
|
||||
else:
|
||||
raise HTTPWrongContentTypeException(
|
||||
"Tried to soup non-html/non-xml data")
|
||||
|
||||
|
||||
data = response_content.decode(response.encoding or fallback_encoding)
|
||||
if json and data:
|
||||
try:
|
||||
return Response(response.status_code, _json.loads(data),
|
||||
|
|
Loading…
Reference in a new issue