Render Http Response(html Content) In Selenium Webdriver(browser)
I am using Requests module to send GET and POST requests to websites and then processing their responses. If the Response.text meets a certain criteria, I want it to be opened up i
Solution 1:
To directly render some HTML with Selenium, you can use the data scheme with the get method:
from selenium import webdriver
importrequestscontent= requests.get("http://stackoverflow.com/").contentdriver= webdriver.Chrome()
driver.get("data:text/html;charset=utf-8," + content)
Or you could write the page with a piece of script:
from selenium import webdriver
import requests
content = requests.get("http://stackoverflow.com/").content
driver = webdriver.Chrome()
driver.execute_script("""
document.location = 'about:blank';
document.open();
document.write(arguments[0]);
document.close();
""", content)
Post a Comment for "Render Http Response(html Content) In Selenium Webdriver(browser)"