How to get the html source of a specific element with selenium?

前端 未结 4 969
梦谈多话
梦谈多话 2020-12-29 14:46

The page I\'m looking at contains :

text 1

text 2

text 3

text 4

4条回答
  •  梦毁少年i
    2020-12-29 15:14

    The selected answer does not work in Python 3 at the time of writing. Instead use this:

    from selenium import webdriver
    
    wd = webdriver.Firefox()
    wd.get(url)
    return wd.execute_script('return window.document.getElementById('1').innerHTML')
    

提交回复
热议问题