Home > Blockchain >  get screenshot of the page using selenium and requests
get screenshot of the page using selenium and requests

Time:09-19

i need to get screenshot of the page. Site https://kad.arbitr.ru/ blocked selenium. After pressing the search button site do nothing. In inspector i see POST request using XHR. How can i execute POST request at this site? Sorry for stupid question, im newbie in Python. Maybe you can suggest other solution

fp = webdriver.FirefoxProfile()
options = Options()
#options.headless = True
driver = webdriver.Firefox(options=options, executable_path=r'FILES\\geckodriver.exe', firefox_profile=fp)
driver.get('https://kad.arbitr.ru/')

#pickle.dump( driver.get_cookies() , open("cookies.pkl","wb")) #Cookies
#response = webdriver.request('POST', 'https://kad.arbitr.ru/Kad/SearchInstances')
#print(response)

for request in driver.requests:
    if request.response:
        print(
            request.url,
            request.response.status_code,
            request.response.headers['Content-Type']
        )

CodePudding user response:

You can take screenshots in a simple way: using driver.save_screenshot('screenshot.png')

CodePudding user response:

You can read more in the first link in google: web

from selenium import webdriver
from PIL import Image
from Screenshot import Screenshot_clipping

fp = webdriver.FirefoxProfile()
options = Options()  # I don't know what is it in your code
driver = webdriver.Firefox(options=options, executable_path=r'FILES\\geckodriver.exe', firefox_profile=fp)
driver.get('https://kad.arbitr.ru/')
driver.save_screenshot(‘ss.png’)  # this is the answer

screenshot = Image.open(‘ss.png’)
screenshot.show()

ss = Screenshot_Clipping.Screenshot()
image = ss.full_Screenshot(driver, save_path=r'.' , image_name='name.png')
  • Related