How to get status code by using selenium.py (python code)

前端 未结 12 1101
深忆病人
深忆病人 2020-11-30 01:01

I am writing a selenium script by python, but I think I don\'t see any information about:

How to get http status code from selenium Python code.

12条回答
  •  自闭症患者
    2020-11-30 01:48

    I used the following trick by using requests to make sure that server is responding first. Then I used driver:

    resp = requests.get(link)
    while resp.status_code != 200:
        resp = requests.get(link)
        if resp.status_code == 200:
            break
    
    html = driver.page_source
    
    soup = BeautifulSoup(html)
    

提交回复
热议问题