我想下载生成的网页Javascript,并将其存储在Python代码中的字符串变量中.单击按钮时会生成页面.
如果我知道我会使用的结果URL,urllib2但事实并非如此.
谢谢
我正在尝试使用Selenium和Python来存储表的内容.我的脚本如下:
import sys
import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://testsite.com")
value = selenium.getTable("table_id_10")
print value
driver.close()
Run Code Online (Sandbox Code Playgroud)
这打开了我感兴趣的网页,然后应该保存我想要的表格的内容.我已经看到了这个问题中使用的语法browser.get_table(),但该程序的开头是从browser=Selenium(...)我不理解的开始的.我不确定我应该使用什么语法,因为selenium.getTable("table_id_10")它不正确.
编辑:
我包含了我正在使用的表的html片段:
<table class="datatable" cellspacing="0" rules="all" border="1" id="table_id_10" style="width:70%;border-collapse:collapse;">
<caption>
<span class="captioninformation right"><a href="Services.aspx" class="functionlink">Return to Services</a></span>Data
</caption><tr>
<th scope="col">Read Date</th><th class="numericdataheader" scope="col">Days</th><th class="numericdataheader" scope="col">Values</th>
</tr><tr>
<td>10/15/2011</td><td class="numericdata">92</td><td class="numericdata">37</td>
</tr><tr class="alternaterows">
<td>7/15/2011</td><td class="numericdata">91</td><td class="numericdata">27</td>
</tr><tr>
<td>4/15/2011</td><td class="numericdata">90</td><td class="numericdata">25</td>
</table>
Run Code Online (Sandbox Code Playgroud)