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 6535627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:23:43+00:00 2026-05-25T10:23:43+00:00

I have this code which gets the HTML source of a page: $page =

  • 0

I have this code which gets the HTML source of a page:

$page = file_get_contents('http://example.com/page.html');
$page = htmlentities($page);

I want to scrape some content from it. For example, say the page’s source contains this:

<strong>technorati.com</strong><br />
Connection failed<br /><br />Pinging <strong>icerocket.com</strong><br />
Connection failed<br /><br />Pinging <strong>weblogs.com</strong><br />
Done<br /><br />Pinging <strong>newsgator.com</strong><br />
Done<br /><br />Pinging <strong>blo.gs</strong><br />
Done<br /><br />Pinging <strong>feedburner.com</strong><br />
Done<br /><br />Pinging <strong>blogstreet.com</strong><br />
Done<br /><br />Pinging <strong>my.yahoo.com</strong><br />
Connection failed<br /><br />Pinging <strong>moreover.com</strong><br />
Connection failed<br /><br />Pinging <strong>newsisfree.com</strong><br />
Done<br />

Is there a way I could scrape this from the source and store it in a variable, so it’ll look like this:

technorati.com Connection failed
icerocket.com Connection failed
eblogs.com Done
Ect.

Of cause the page is dynamic which is why I’m having a problem. Could I maybe search for each site in the source? But then how would I get the result which is after it? (Connection failed / Done)
Thanks a lot for the help!

  • 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-25T10:23:44+00:00Added an answer on May 25, 2026 at 10:23 am

    I have tried scraping multiple sites using the simple HTML DOM PHP library, which can be obtained here: http://simplehtmldom.sourceforge.net/

    Then using code like this:

    <?php
    include_once 'simple_html_dom.php';
    
    $url = "http://slashdot.org/";
    $html = file_get_html($url);
    
    //remove additional spaces
    $pat[0] = "/^\s+/";
    $pat[1] = "/\s{2,}/";
    $pat[2] = "/\s+\$/";
    $rep[0] = "";
    $rep[1] = " ";
    $rep[2] = "";
    
    foreach($html->find('h2') as $heading) { //for each heading
            //find all spans with a inside then echo the found text out
            echo preg_replace($pat, $rep, $heading->find('span a', 0)->plaintext) . "\n"; 
    }
    ?>
    

    This results in something like:

    5.8 Earthquake Hits East Coast of the US
    Origins of Lager Found In Argentina
    Inside Oregon State University's Open Source Lab
    WebAPI: Mozilla Proposes Open App Interface For Smartphones
    Using Tablets Becoming Popular Bathroom Activity
    The Syrian Government's Internet Strategy
    Deus Ex: Human Revolution Released
    Taken Over By Aliens? Google Has It Covered
    The GIMP Now Has a Working Single-Window Mode
    Zombie Cookies Just Won't Die
    Motorola's Most Important 18 Patents
    MK-1 Robotic Arm Capable of Near-Human Dexterity, Dancing
    Evangelical Scientists Debate Creation Story
    Android On HP TouchPad
    Google Street View Gets Israeli Government's Nod
    Internet Restored In Tripoli As Rebels Take Control
    GA Tech: Internet's Mid-Layers Vulnerable To Attack
    Serious Crypto Bug Found In PHP 5.3.7
    Twitter To Meet With UK Government About Riots
    EU Central Court Could Validate Software Patents
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: myVariable which I want to change into trace(myVariable: + myVariable);
I have a question concerning this code which I want to run on QNX:
I have some code in C# which has a com wrapper. This com wrapper
I have this code, which gets an clicked div id: $(document).ready(function(){ $(.playitem).click(function(){ pos =
I have a simple java code which gets html text from the input url:
I have this code, which works fine, but I would like to be able
I have this php code, with which I am trying to generate a popup
I have added some code which compiles cleanly and have just received this Windows
I have this code in jQuery, that I want to reimplement with the prototype
My q and a page sucks - it's this: http://rankingclimber.com/qa.php I checked out http://www.text-link-ads.com/r/faq

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.