Answer the question
In order to leave comments, you need to log in
How to take a screenshot of a schedule on a website using selenium?
There is a task to take a screenshot of the class schedule on the site, I tried to do it through the size, but the number of pairs does not always match the default sizes, especially since all items do not always fit into the screenshot window. I tried with driver.find_element_by_class_name but it will only screen the first element there, and with driver.find_elements_by_class_name it returns a list, so you can’t make a screen. Here is the site: almetpt.ru/2020/site/schedulegroups/0/1/2020-03-17 Tell me how you can make a screen for each group separately)
Answer the question
In order to leave comments, you need to log in
The element's screenshot is in the .screenshot_as_png property. This is a stream of bytes, written in byte mode.
blocks = driver.find_elements_by_xpath("//*[contains(@class, 'd-inline-block')]")
for i, block in enumerate(blocks):
with open(file=f'{i}.png', mode='wb') as f:
f.write(block.screenshot_as_png)
NoXXik ScriptKiddo
via
POST
to
http://127.0.0.1:55105/session/4efe9b351b24b0869d34bf24ca45af0e/chromium/send_command_and_get_result
params: {"cmd": "Page.captureScreenshot", "params": {"clip": {"x": 32, "y": 469, "width": 235, "height": 76, "scale": 1}}}
...
return base64.b64decode(response['value']['data'])
viewport
will have its own) Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question