如何在Python中使用Selenium从具有隐藏元素的动态折叠表中提取数据

时间:2019-07-24 09:16:57

标签: python selenium selenium-chromedriver

我尝试从https://patents.google.com/patent/JP2009517369A/en?oq=JP2009517369抓取这20个分类,从中显示第一个分类,而其他分类则隐藏在可扩展部分中。

我已经尝试使用来获得第一个可见的

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//div[@class='style-scope classification-tree' and not(@hidden)]/state-modifier[@class='code style-scope classification-tree']/a[@class='style-scope state-modifier']"))).get_attribute("innerHTML") 

但是,它引发了一个异常,我不知道为什么。因此,我认为刮刮整个表格会更容易,但是大多数元素都折叠了。

有什么方法可以抓取动态隐藏表? 谢谢您的帮助!

1 个答案:

答案 0 :(得分:0)

前两个选项应打印值y:1 to 101

features_placeholder = tf.placeholder(tf.float32, shape=[None,None],name="input_features")
labels_placeholder = tf.placeholder(tf.float32, shape=[None,1],name = "input_labels")

iterator = (tf.data.Dataset.from_tensor_slices((features_placeholder, labels_placeholder))
           .apply(sliding.sliding_window_batch(timestep=100, stride=1))
           .batch(10)
           .make_initializable_iterator()
           )
next_element = iterator.get_next(name="batch")
init_op = iterator.initializer
saveable = tf.contrib.data.make_saveable_from_iterator(iterator)

OR

C07C311/51

但是,如果您没有获得期望的值,请尝试最后一个。这应该会打印任何隐藏的内容。

print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//div[@class='style-scope classification-tree' and not(@hidden)]/state-modifier[@class='code style-scope classification-tree']/a[@class='style-scope state-modifier']"))).text)