我想要在selenium webdriver中獲取標題。一些類似以下內容:如何在python selenium-webdriver中獲取標題
>>> import requests
>>> res=requests.get('http://google.com')
>>> print res.headers
我需要,因爲它支持Flash和我需要測試一個網頁一些其他的事情要使用Chrome
的webdriver。以下是我迄今爲止在硒:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('https://login.comcast.net/login?r=comcast.net&s=oauth&continue=https%3A%2F%2Flogin.comcast.net%2Foauth%2Fauthorize%3Fclient_id%3Dxtv-account-selector%26redirect_uri%3Dhttps%3A%2F%2Fxtv-pil.xfinity.com%2Fxtv-authn%2Fxfinity-cb%26response_type%3Dcode%26scope%3Dopenid%2520https%3A%2F%2Flogin.comcast.net%2Fapi%2Flogin%26state%3Dhttps%3A%2F%2Ftv.xfinity.com%2Fpartner-success.html%26prompt%3Dlogin%26response%3D1&reqId=18737431-624b-44cb-adf0-2a85d91bd662&forceAuthn=1&client_id=xtv-account-selector')
driver.find_element_by_css_selector('#user').send_keys('[email protected]')
driver.find_element_by_css_selector('#passwd').send_keys('XXY')
driver.find_element_by_css_selector('#passwd').submit()
print driver.headers ### How to do this?
我已經看到了建議運行一個完整的硒服務器以獲取該信息(https://github.com/derekargueta/selenium-profiler)一些其他的答案。如何用Webdriver使用類似於上面的內容來獲得它?
能否請您詳細說明你想提取和什麼什麼頭?謝謝。 – alecxe
很確定你不能開箱即用。 –