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

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

The page I\'m looking at contains :

text 1

text 2

text 3

text 4

4条回答
  •  攒了一身酷
    2020-12-29 15:10

    The following code will give you the HTML in the div element:

    sel = selenium('localhost', 4444, browser, my_url)
    html = sel.get_eval("this.browserbot.getCurrentWindow().document.getElementById('1').innerHTML")
    

    then you can use BeautifulSoup to parse it and extract what you really want.

    I hope it helps

提交回复
热议问题