Saving pages with Selenium

后端 未结 2 1129
自闭症患者
自闭症患者 2021-01-26 19:11

I will try again.

The code below I copied from another site and the user say it works (shows a screenshot).Original code

I tested the code: No error, but no fil

2条回答
  •  春和景丽
    2021-01-26 19:39

    from selenium import webdriver
    
    driver = webdriver.Chrome(executable_path=r"C:\Program Files (x86)\Selenium\chromedriver.exe")
    
    driver.get("http://www.example.com")
    with open('page.html', 'w+') as f:
        f.write(driver.page_source)
        f.close()
    

    Must work

提交回复
热议问题