Python 使用phantomjs和selenium从linkedin获取页面值

Python 使用phantomjs和selenium从linkedin获取页面值,python,selenium,web-scraping,phantomjs,Python,Selenium,Web Scraping,Phantomjs,我正在尝试使用phantomjs和selenium从链接中获取用户详细信息 def getLinkedinData(self): result = {} driver = webdriver.PhantomJS('/usr/local/bin/phantomjs' ,service_args=service_args) driver.set_window_size(1124, 850) google_news_trends = [] driver.get(

我正在尝试使用phantomjs和selenium从链接中获取用户详细信息

def getLinkedinData(self):
    result = {}
    driver = webdriver.PhantomJS('/usr/local/bin/phantomjs' ,service_args=service_args)
    driver.set_window_size(1124, 850)
    google_news_trends = []
    driver.get("https://www.linkedin.com/pub/omkar-mujgond/5/aa0/b74")
    try:
        print driver.find_element_by_class_name('locality').text
    except:
        import traceback
        traceback.print_exc()
虽然代码是正确的,但我得到了

NoSuchElementException: Message: {"errorMessage":"Unable to find element with class name 'locality'","request":{"headers":{"Accept":"application/json","Accept-Encoding":"identity","Connection":"close","Content-Length":"97","Content-Type":"application/json;charset=UTF-8","Host":"127.0.0.1:47844","User-Agent":"Python-urllib/2.7"},"httpVersion":"1.1","method":"POST","post":"{\"using\": \"class name\", \"sessionId\": \"7e474060-2fab-11e5-b0d9-db8d38927a05\", \"value\": \"locality\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/7e474060-2fab-11e5-b0d9-db8d38927a05/element"}}
Screenshot: available via screen

你有没有截图看看你是否在正确的页面上?您是否打印了页面源以查看元素是否存在?您是否在该元素从未出现的移动页面上?@ArtjomB.:我在正确的页面上,是的,我在该元素所在的web视图页面上appears@niper你能做到吗。我也遇到了同样的问题,当我尝试使用phantomjs时,我得到的是空的html。@nlper-这个工作正常吗?