T
T
trubachw2020-12-20 13:00:21
PHP
trubachw, 2020-12-20 13:00:21

Need help with the site, namely the screen of the page on the server side. How to do it?

Hello everyone, I'm just starting to learn web development and I have a question about the implementation of one function.
I have a task to make a screen of a certain area of ​​the site (in the future it will be a screen of a certain area of ​​the map selected by the user) on the server side. So that after clicking on the button, the site takes a screen on its page of a certain area and opens it on another page (in the future it will be editing this screenshot). Please tell me how to take a screenshot of the selected area?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
M
mletov, 2020-12-20
@mletov

On the server side, no way. The screen is still made on the client, and then sent to the server if you need to save it somewhere.
And on the client, for example:
https://www.geeksforgeeks.org/how-to-take-screensh...
Or Google->"screenshot page javascript"

S
Stalker_RED, 2020-12-20
@Stalker_RED

The easiest way is from a browser. In chrome, open the console (f12), press ctrl + shift + p there, write full size screenshot there.
if you need it on the server side, then look towards headless browsers .

L
Larisa Moroz, 2020-12-24
@larisamoroz

you can do everything in PHP
with cutycapt and xvfb-run to help you,
but you need to have access to installing software on the server
, I have this command in the screenshots

exec('xvfb-run -a --server-args="-screen 0, 520x520x24" cutycapt --url=\'' . $pageUrl . '\' --min-width=520 --min-height=340 --out=\'' . $screenshotPath . '\' 2>&1', $execoutput);

T
tempick, 2020-12-20
@tempick

On the server side - you can use Node.js+puppeteer.
https://pptr.dev/#?product=Puppeteer&version=v5.5....
The first code example - saving a screenshot of the site to a jpg file
With a selected area, it will be a little more complicated, but quite feasible.

I
Igor Dudchenko, 2020-12-24
@XOKyUCT

Successfully using browsershot for such task

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question