Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7160467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:24:14+00:00 2026-05-28T13:24:14+00:00

The script I am using ‘gets’ a html page and parses is showing only

  • 0

The script I am using ‘gets’ a html page and parses is showing only the .jpg images within, but I need to make some modifications and when i do it simply fails…

This works:

include('simple_html_dom.php');

function getUrlAddress() {
    $url = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
    return $url .'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}

$html = file_get_html($url);

foreach($html->find('img[src$=jpg]') as $e)
    echo '<img src='.$e->src .'><br>';

However, there are some problems… I only want to show images over a certain size, plus some site do not display full URL in the img tag and so need to try to get around that too… so I have done the following:

include('simple_html_dom.php');

function getUrlAddress() {
    $url = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
    return $url .'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}

$html = file_get_html($url);

foreach($html->find('img[src$=jpg]') as $e)
   $image = $e->src;

// check to see if src has domain
if (preg_match("/http/", $e->src)) { 
    $image = $image; 
} else {
    $parts = explode("/",$url);
    $image = $parts['0']."//".$parts[1].$parts[2].$e->src;
}

$size = getimagesize($image);

echo "<br /><br />size is {$size[0]}";
echo '<img src='.$image.'><br>';

This works, but only returns the first image.

On the example link below there are 5 images, which the first code shows but does not display them as the src is without the leading domain

Example link as mentioned above

Is there a better way to do this? And why does the loop fail?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:24:14+00:00Added an answer on May 28, 2026 at 1:24 pm

    You seem to be missing a {:

    foreach($html->find('img[src$=jpg]') as $e) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to host a python script using an apache web server, but the
I'm currently writing a small script using pygame, but I don't believe this question
So I have successfully created an upload script using the API, but now I
If I write a python script using only python standard libraries, using Python 2.6
I'm writing a script using BaseHTTPRequestHandler class. And in do_GET(self) method I need to
I'm trying to run a bash script using shell_exec but It doesnt seem to
I created an autosuggest script using php, ajax and some css but I can't
I have a jQuery script using .live() to load it's page content. $('#content').load(content.php? +
I've got a really simple login script using PHP's sessions to limit access, but
I recorded a script using the Selenium IDE extension for Firefox, and I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.