如何解决python Http响应包含\ n字符
我正在使用python HTTP Request程序包来进行HTTP get调用。这个工作正常,我可以得到回应。 但是响应包含HTML标记之间的\ n。我验证了URL的源代码,并且确实在HTML代码之间存在新行,但这在呈现HTML时不会造成损害,但是在HTTP响应中,当我尝试解析HTML时,会添加这些新行。
with requests.get(url,**get_req_parameters(proxyDict)) as req:
http_response_code = req.status_code
html_content = req.content
HTML code:
<!doctype html>
<html xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml" lang="en-US" >
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="initial-scale=1">
<!-- This is Squarespace. --><!-- heitest2 -->
Http响应添加\ n
<!doctype html>\n<html xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml" lang="en-US" >\n <head>\n <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">\n
我在HTTP响应内容中不需要这些换行符(\ n)。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。