R
R
romaaa322018-06-05 19:07:54
PHP
romaaa32, 2018-06-05 19:07:54

How to extract an image from a page?

5b16b26a42ea6575453852.jpeg
Link to the picture with the question "Note" http://site.ru/captcha_question/629
The function copy();copies and creates an empty text.
file_​get_​contents ----- file_​put_​contentsthe same.
Curl with headers, cookies and everything else opens that picture as if on a PC you open it as a text file:

PNG  IHDR9jgAMAasRGB cHRMz&u0`:pQ<bKGD	X pHYsHHFk>'WIDATxڵ]y\TDz@My █QFԨƨQ\/qKD# -Gb5nQQ+ ...

Tell me which direction to go. Nothing works.
If you open this page through Curl as in the screenshot, all pictures are displayed. Can you recognize her here?
If you write this after Curl:
echo "<img src='http://site.ru/captcha_question/629' />";
The picture is displayed correctly

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kim, 2018-06-05
@kimono

$img = file_get_contents('http://site.ru/nota.jpg');
file_put_contents('/var/www/site.domain/images/nota.jpg', $img);
echo '<img src="/images/nota.jpg" />';

R
romaaa32, 2018-06-05
@romaaa32

Solution found.
I found this line with a sniffer: Content-Transfer-Encoding: binary
Then I did this: Encoded and decoded in base64

...
$t1 = curl($cookie, $url_game.'/captcha_question/629', $url_game) or die('Ошибка: 2');

$tr = base64_encode($t1);

$tr = base64_decode($tr);
file_put_contents('img.png', $tr);

The result is a working desired picture)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question