我需要分析网页内容。页面有javascrips。 你能告诉我比使用硒更好的方法吗?你知道吗
如果没有: 加载到浏览器中的页面包含以下元素:
<div class="js-container"> <table class="zebra" style="width: 100%;">
<tbody><tr>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>
<tr>
<td>A1</td>
<td>A2</td>
<td>
<a href="http://X" style="color: black">T1</a>
</td>
</tr>
<tr>
....
</tr>
....
我需要逐项阅读一张表格。我跑例如:
myList = myDriver.find_elements_by_class_name("js-container")
。你知道吗
那么如何获取“js container”对象的内部元素呢?你知道吗
生成myList的唯一元素是:print (myList[0])
:
<selenium.webdriver.remote.webelement.WebElement (session="61238", element="{71293}")>
也许你需要给它喂奶driver.page\u源. 它是一个python工具,可以基于web页面构建树。 BeautifulSoup document
硒可以做得很好。你知道吗
此代码获取
TABLE
标记的所有子体,删除innerHTML
字符串开头之后的所有内容并打印结果。outerHTML
包含元素本身和所有子元素,innerHTML
只包含子元素。因此,为了只获取元素本身的HTML,我们需要从outerHTML
中删除innerHTML
。你知道吗相关问题 更多 >
编程相关推荐