前提・実現したいこと
Pythonでseleniumを使用してhrefのURLを取得したいのですが、うまくいきません。。。
find_element_by_css_selectorで要素を取得して、
そこから取得しようとしたのですが。。。
ご教授いただければと思います。
発生している問題・エラーメッセージ
Traceback (most recent call last): File "/Users/tetetete/PycharmProjects/test/test.py", line 65, in <module> print(testInput("a").get_attribute("href")) TypeError: 'WebElement' object is not callable
該当のソースコード
取得したいHTMLの抜粋です。
html
1<div class="test" style="width: 100%;"> 2 <a href="https://www.test"> 3</div>
取得用ソースの抜粋です。
python
1testInput = driver.find_element_by_css_selector(".test") 2print(testInput("a").get_attribute("href"))
試したこと
Xpathで取得しようとしましたがダメでした。
tagInput.get_attribute("aria-expanded")
補足情報(FW/ツールのバージョンなど)
python3.6
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/06/08 14:58