私はPythonでスクリプトを書いて、Webページの特定のリンクをクリックするためにseleniumと組み合わせて使用しました。私の唯一の目的は、そのリンクをクリックすることです。私はいくつかの方法で試しましたが、うまく機能しません。 Webページへ問題のあるリンクでクリックを開始できません
リンク:URL
スクリプト私が試してみました:あなたは上記のURLに従った場合
<div class="k-grid-content k-auto-scrollable">
<table class="k-selectable" data-role="selectable" role="grid" style="touch-action: none;">
<colgroup>
<col style="width:100px"/>
<col style="width:210px"/>
<col/>
<col/>
<col style="width:120px"/>
</colgroup>
<tbody role="rowgroup">
<tr class="rowHover" data-uid="1fccd732-cd65-4393-b1be-66786fe9ee60" role="row">
<td role="gridcell">
R016698
</td>
<td role="gridcell">
R-13-0410-0620-50000
</td>
<td role="gridcell" style="display:none">
O0485204
</td>
<td role="gridcell">
GOOCH, PHILIP L
</td>
<td role="gridcell">
319 LIZZIE ST, TAYLOR, TX 76574
</td>
<td role="gridcell" style="display:none">
DOAK ADDITION, BLOCK 62, LOT 5
</td>
<td role="gridcell" style="display:none">
T541
</td>
<td role="gridcell" style="display:none">
</td>
<td role="gridcell" style="display:none">
S3564 - Doak Addition
</td>
<td role="gridcell" style="display:none">
Real
</td>
<td role="gridcell">
<div style="text-align:right;width:100%">
$46,785
</div>
</td>
</tr>
</tbody>
</table>
</div>
:クリック可能なリンクが内にある必要があり、その中
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
wait = WebDriverWait(driver, 10)
driver.get("use_above_url")
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".k-selectable"))).click()
driver.quit()
要素をこの正確なテキストR016698 R-13-0410-0620-50000 GOOCH, PHILIP L 319 LIZZIE ST, TAYLOR, TX 76574
を含むそのWebページの行を見ることができます。それが私がクリックしたい場所です。そのリンク上にマウスを置くと、リンク全体に影がつきます。私は何をしたいのかがはっきりしていることを願っています。前もって感謝します。
はいはいはい!!!あなたはそれをしました。どうもありがとう。 – SIM
同じ名前の別のクラスがあることを知るには?非常に好奇心。再度、感謝します。 – SIM
'@ class' nameは一意の識別子ではありません。これはHTML要素に特定のスタイルを適用するために使用され、同じクラス名を持つ多くの要素が存在するかもしれません... 'print(len(driver.find_elements(your_selector)))'でデバッグできます。出力に '1'以上の値がある場合は、より具体的なセレクタを適用する必要があります – Andersson