How to grab headers in python selenium-webdriver

后端 未结 5 1332
野趣味
野趣味 2021-01-01 23:37

I am trying to grab the headers in selenium webdriver. Something similar to the following:

>>> import requests
>>> res=requests.get(\'http:         


        
5条回答
  •  抹茶落季
    2021-01-01 23:55

    You could try Mobilenium, a python package (still in development) that binds BrowserMob Proxy and Selenium.

    An usage example:

    >>> from mobilenium import mobidriver
    >>>
    >>> browsermob_path = 'path/to/browsermob-proxy'
    >>> mob = mobidriver.Firefox(browsermob_binary=browsermob_path)
    >>> mob.get('http://python-requests.org')
    301
    >>> mob.response['redirectURL']
    'http://docs.python-requests.org'
    >>> mob.headers['Content-Type']
    'application/json; charset=utf8'
    >>> mob.title
    'Requests: HTTP for Humans \u2014 Requests 2.13.0 documentation'
    >>> mob.find_elements_by_tag_name('strong')[1].text
    'Behold, the power of Requests'
    

提交回复
热议问题