0

I have a script that gets and displays part of an external website.

https://pentiger.com/wycieczki.php

<?php
$config['base_url'] = 'www.ampolinc.com/';
$curl = curl_init('http://www.ampolinc.com/wycieczki.php');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

$page = curl_exec($curl);

if(curl_errno($curl)) // check for execution errors
   {
echo 'Scraper error: ' . curl_error($curl);
exit;
  }

curl_close($curl);


$regex = '/<td width=\"694\" bgcolor=\"#FFFFFF\">(.*?)<table width=\"709\" 
cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"margin:5px 0px 0px 167px;\">.<tr><td>/s';


if ( preg_match($regex, $page, $list) )
  {

$list= str_replace('plan','print',$list);

<base href="http://ampolinc.com/">
echo "<font size = \"9\">";
echo $list[0]; //prints it to your page
echo "</font>";       
   }

else 
print "Not found"; 


?>

but the images in Chrome do not display, when I click copy image url it copies fine. I tried in Safari and images display. Any idea why? thanks.

How it looks in Chrome

How it looks on Safari

  • 1
    This may happen if the request is not secured. Did you try https:// instead of http:// in the curl_init? – Mana S Dec 14 '21 at 00:49
  • 1
    The (PHP) code you've posted runs on your webserver and grabs data from the external target webserver; there really are no webbrowsers in the loop there. Can you show the html sourcecode from both browsers ? (CTRL U in webbrowser) – Raxi Dec 14 '21 at 00:50
  • 1
    Both browsers should receive identical code from the php app, but if the html is poorly formatted, one browser may work around that better than the other. Also, not really on topic for your question, but html should be parsed, not regex matched as you do here, its incredibly unreliable and fragile; and php has lots of different forms of html parsing support build-in. – Raxi Dec 14 '21 at 00:52
  • What do the Chrome dev-tools _Console_ and _Network_ panels say? – Phil Dec 14 '21 at 00:54
  • This code was suggested some time agon on stackoverflow, couple years back, and it worked fine before. It runs on my website and ad gets info from another. Mixed Content: The page at '' was loaded over HTTPS, but requested an insecure element ''. This request was automatically upgraded to HTTPS, For more information see download.php:159 GET https://ampolinc.com/ObrWycieczek/1604.jpg net::ERR_CERT_AUTHORITY_INVALID download.php:1 GET https://ampolinc.com/miesiace.jpg net::ERR_CERT_AUTHORITY_INVALID download.php:13 GET https://ampolinc.com/ObrWycieczek/1613.jpg – user1736969 Dec 14 '21 at 01:01
  • It might have something to do with the main website not using https. – user1736969 Dec 14 '21 at 01:04
  • Is [this](https://stackoverflow.com/questions/35178135/how-to-fix-insecure-content-was-loaded-over-https-but-requested-an-insecure-re/35178323) help? Also [this fix](https://web.dev/fixing-mixed-content/#fixing-mixed-content) guideline. – vee Dec 14 '21 at 01:40
  • It would work if the main site was secure and it's not. I asked the owner to install SSL certificate, this should fix the problem. Thanks to all for your help. – user1736969 Dec 14 '21 at 01:46

0 Answers0