如何在selenium python中抓取突出显示的表数据

我正在尝试从数据库中仅抓取硒中选定的高亮行

我只想要蓝色、紫色和黄色的行

https://img1.sycdn.imooc.com/658e6f760001a48409770521.jpg

共 2356 行


这是我的代码:


import pandas as pd

 

from selenium import webdriver

  

from selenium.webdriver.common.keys import Keys 



driver = webdriver.Chrome() 


driver.get ("https://www.fieo.org/Offrings-from-Indian-Exporters.php")


que=driver.find_element_by_xpath("//*[@id='contant-contant']/table/tbody/tr[10]/td[3]/b/a")


que.click()


德玛西亚99
浏览 111回答 1
1回答

慕无忌1623718

这是其中之一的示例。#,[@bgcolor='#C6C600'],[@bgcolor='#70B8B8']elements=WebDriverWait(driver, 30).until(EC.visibility_of_all_elements_located((By.XPATH, "//tr[@bgcolor='#C184FF']")))#print(len(elements))for elem in elements:&nbsp; &nbsp; print(elem.get_attribute('innerHTML'))输出<td><input type="checkbox" name="id[]" value="49516">3F INDUSTRIES LIMITED&nbsp;&nbsp;<strong>[TH]</strong></td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td>TURMERIC</td>……等等。如果您只想要文本,请使用 elem.text。进口from selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWait&nbsp;from selenium.webdriver.support import expected_conditions as EC
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python