比如:
<div class="content"><p> The ele is cu <sub>2</sub></p></div>
driver = webdriver.PhantomJS(executable_path='/usr/local/bin/phantomjs')
driver.get(request.url)
content=driver.find_element_by_xpath("//div[@class='content']/p").text()
似乎获取不了The ele is cu <sub>2</sub>
???
可以的,先用xpath定位到<div>这个标签,再这个下边定位<p>标签。
如果没记错,使用text属性就可以取到the ele is cu
定位到<div>这个标签,再这个下边定位标签,使用text,或者叫get_text属性(具体的你需要查询下),
就可以获取到2