0
我使用selenium和ChromeDriver来测试XML响应。在Selenium Chrome驱动程序中获取真实的XML源代码
的反应是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<d>test</d>
但如果我get
该URL的硒,铬会自动呈现XML,使得page_source
脏。
>>> from selenium import webdriver
>>> b=webdriver.Chrome()
>>> b.get('http://127.0.0.1/test.xml')
>>> b.page_source
'<?xml version="1.0" encoding="UTF-8"?><html xmlns="http://www.w3.org/1999/xhtml"><head><style id="xml-viewer-style">/* Copyright 2014 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file...'
(你可以看到Chrome浏览器添加一个“XML查看”页面源)
什么是让XML的真正来源的最佳做法?
ps。这个XML是由铬扩展返回的,我将使用硒进行测试,因此“使用requests
或urllib
”不是一个解决方案。