Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.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 如何从class=";获取值;表格行“;id=”号;“视图”;在SeleniumWebDriver中?_Python_Css_Selenium_Beautifulsoup - Fatal编程技术网

Python 如何从class=";获取值;表格行“;id=”号;“视图”;在SeleniumWebDriver中?

Python 如何从class=";获取值;表格行“;id=”号;“视图”;在SeleniumWebDriver中?,python,css,selenium,beautifulsoup,Python,Css,Selenium,Beautifulsoup,[![我当前的代码正在运行,但我希望与使用python的selenium中的任何脚本一样使用其他脚本 from bs4 import BeautifulSoup soup = BeautifulSoup(driver.page_source) all_text_tags = soup.find("div",{"id" :"view"}) labels_tag = all_text_tags.find_all("label") count = 0 for i, j in zip(all_text_

[![我当前的代码正在运行,但我希望与使用python的selenium中的任何脚本一样使用其他脚本

from bs4 import BeautifulSoup
soup = BeautifulSoup(driver.page_source)
all_text_tags = soup.find("div",{"id" :"view"})
labels_tag = all_text_tags.find_all("label")
count = 0
for i, j in zip(all_text_tags.find_all("input"), labels_tag):
    count += 1
    if i['value'] != "":
        print(i['value'])]

使用
selenium
输入标签获取

使用任一css选择器

for inputtag in driver.find_elements_by_css_selector("#view input"):
    print(inputtag.get_attribute("value"))


从css选择器下面的标签标签使用中获取值

for labeltag in driver.find_elements_by_css_selector("#view [id^='label']"):
    print(labeltag.text)

非常感谢您能解释一下这个代码(“#视图输入”)?@pycoderr:
#view
-选择具有视图Id的元素。和
#view input
-DOM后代组合符。所有输入标记都是#view标记的子项
for labeltag in driver.find_elements_by_css_selector("#view [id^='label']"):
    print(labeltag.text)