Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.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 3.x 在selenium(python)中迭代div_Python 3.x_Selenium - Fatal编程技术网

Python 3.x 在selenium(python)中迭代div

Python 3.x 在selenium(python)中迭代div,python-3.x,selenium,Python 3.x,Selenium,您好,我正在使用python在selenium中制作scraper。网络的结构: 我想得到所有的价格和一天。但我甚至无法将div作为iterable对象捕获,因为下面的代码返回TypeError“objectnotinterable”…: 我做错了什么?我花了几个小时寻找我的问题的答案,但没有找到。提前感谢您的帮助 //编辑 感谢@xxMrPHDxx 太棒了 prices = driver.find_elements_by_xpath(".//span[@class='value']")

您好,我正在使用python在selenium中制作scraper。网络的结构:

我想得到所有的价格和一天。但我甚至无法将div作为iterable对象捕获,因为下面的代码返回TypeError“objectnotinterable”…:

我做错了什么?我花了几个小时寻找我的问题的答案,但没有找到。提前感谢您的帮助

//编辑 感谢@xxMrPHDxx 太棒了

prices = driver.find_elements_by_xpath(".//span[@class='value']")    
for p in prices:
    print(p.text)

对于
months
,您可能希望使用
find\u elements\u by\u xpath
函数,而不是返回列表的函数,请阅读原因。粘贴代码并正确格式化。我不明白。我正在使用find_elements_by_xpath函数。
prices = driver.find_elements_by_xpath(".//span[@class='value']")    
for p in prices:
    print(p.text)