Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用Beauty Soup显示onmouseover属性中的文本_Python_Html_Beautifulsoup_Selenium Chromedriver_Onmouseover - Fatal编程技术网

Python 使用Beauty Soup显示onmouseover属性中的文本

Python 使用Beauty Soup显示onmouseover属性中的文本,python,html,beautifulsoup,selenium-chromedriver,onmouseover,Python,Html,Beautifulsoup,Selenium Chromedriver,Onmouseover,这个问题的不同版本已经被问到: 基本上,我想做的是从鼠标悬停时显示的表格单元格中获取文本,如下图所示。我用Python编写代码并使用BeautifulSoup 我可以使用Beautiful Soup成功获得onmouseover属性: <td class="right odds down"><div onmouseout="delayHideTip()" onmouseover="page.hist(this,'P-0.00-0-0','357osx2s5a4x0x7ot

这个问题的不同版本已经被问到:

基本上,我想做的是从鼠标悬停时显示的表格单元格中获取文本,如下图所示。我用Python编写代码并使用BeautifulSoup

我可以使用Beautiful Soup成功获得onmouseover属性:

<td class="right odds down"><div onmouseout="delayHideTip()" onmouseover="page.hist(this,'P-0.00-0-0','357osx2s5a4x0x7ot9r',2,event,0,1)">+340</div></td>  

<div onmouseout="delayHideTip()" onmouseover="page.hist(this,'P-0.00-0-0','357osx2s5a4x0x7ot9r',2,event,0,1)">+340</div>

非常感谢您的帮助

好的,答案实际上是使用Selenium webdriver获取信息。 例如,如果我们想从bwin获得初始赔率,在赔率数据表的第8行: 其x路径为:

 "//*[@id =" + '"odds-data-table"' + "]/div[1]/table/tbody/tr[8]/td[2]")
我们可以通过将鼠标悬停在初始奇数数据上并获取如下信息来检索初始奇数数据:

 initial_odd_data = driver.find_element_by_xpath("//*[@id =" + '"odds-data-table"' + "]/div[1]/table/tbody/tr[8]/td[2]")
hov = ActionChains(driver).move_to_element(initial_odd_data)
hov.perform()
data_in_the_bubble = driver.find_element_by_xpath("//*[@id='tooltiptext']")
hover_data = data_in_the_bubble.get_attribute("innerHTML")
 initial_odd_data = driver.find_element_by_xpath("//*[@id =" + '"odds-data-table"' + "]/div[1]/table/tbody/tr[8]/td[2]")
hov = ActionChains(driver).move_to_element(initial_odd_data)
hov.perform()
data_in_the_bubble = driver.find_element_by_xpath("//*[@id='tooltiptext']")
hover_data = data_in_the_bubble.get_attribute("innerHTML")