0
을 통해 나는 현재 파이썬에게루프의 모든 요소 XPath는
HTML을한다 사용하는 셀레늄을 배우고 얻을 : 나는 시도 XPath는 을 통해,
<ol class="item-section">
<li>
<div class="abc xyz">
<div class="foo qwe">
<a href="/watch123"></a>
</div>
</div>
</li>
<li>
<div class="abc xyz">
<div class="foo qwe">
<a href="/watch456"></a>
</div>
</div>
</li>
<li>
<div class="abc xyz">
<div class="foo qwe">
<a href="/watch678"></a>
</div>
</div>
</li>
</ol>
내가 목록에서 모든하는 HREF를 얻으려면
html_list = driver.find_element_by_class_name("item-section")
items = html_list.find_elements_by_tag_name("li")
stack=[]
index = 1
for item in items:
index+=1
link = item.find_element_by_xpath("//div[@class='foo qwe']["+index+"]/a")
print (index,"---> ",link.get_attribute("href"))
하지만 난 그냥 사용하는 경우이 오류 Can't convert 'int' object to str implicitly
을 제공
link = item.find_element_by_xpath("//div[@class='foo qwe']/a")
난 당신이 요소의 목록을 얻을 수
를 사용하여 얻을 수 ("// DIV의 [에 @ 클래스 = 'foo는 qwe ']/a ")' – Madhan
감사합니다 !! 그것은 – MrRobot9
@ Madhan 대답으로 게시해야하고 대답은 대답으로 받아 들여야합니다 .... 덕분에 –