首页 新闻 会员 周边

python使用requests 获取网页信息文本不是XML格式文件

0
悬赏园豆:10 [待解决问题]

url='https://jobs.51job.com/beijing/javakaifa/'
res=requests.get(url)
res.encoding='gbk'
print('res is:',res)

print(res.encoding)

print('res .text is:',res.text)

最终打印出来的res.text是这种格式,而不是XML格式,是什么原因?
html, body, div, span, p{
margin:0;
padding:0;
border:0;
outline:0;
font-size:100%;
vertical-align:baseline;
background:transparent;
}
body{
background: #fff;
}
.head{
position: relative;
height: 70px;
padding-left: 25px;
border-bottom: 1px solid #EBECEC;
}

	.content{
		width: 1000px;
		min-height: 500px;
		margin-top: 90px;
		margin-left: auto;
		margin-right: auto;
	}
	.left{
		width: 510px;
		height: 382px;
		float: left;
		background: url(https://g.alicdn.com/sd-base/static/1.0.10/image/nocapture/robot.png) no-
山高月小s的主页 山高月小s | 初学一级 | 园豆:192
提问于:2022-05-24 12:10
< >
分享
所有回答(1)
0

抛开 requests ,先用 postman 试试能不能获取到 XML 格式的返回

〆灬丶 | 园豆:2287 (老鸟四级) | 2022-05-24 14:30

postman需要安装对吗,电脑不能随意安装软件,还有别的办法吗

支持(0) 反对(0) 山高月小s | 园豆:192 (初学一级) | 2022-05-25 15:53

@山高月小s: res.text 就是一般的 str (内容是 HTML);我没看出啥东西, 你要不用 bs4 转一遍?

支持(0) 反对(0) 〆灬丶 | 园豆:2287 (老鸟四级) | 2022-05-25 17:23
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册