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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:51:42+00:00 2026-05-31T03:51:42+00:00

I am having trouble fetching content from a web-page, actually i wanted to fetch

  • 0

I am having trouble fetching content from a web-page,
actually i wanted to fetch all the inner text from div name displaybody

but my code doesn’t seems working, it is fetching all the content of the page instead of fetching the content from displaybody div and after 4 page successfully fetched i get an error,

Fatal error: Maximum execution time of 30 seconds exceeded in E:\Installations\xampp\htdocs\wp\simple_html_dom.php on line 127

Here is the code for the script,

I want my script to open all the sub-pages(/txt/any number) inside the url mentioned in the code and fetched the content from its particular div (displaybody)

<?php

    $request_url ='http://www.zedge.net/txts/4519/200-3-1/';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $request_url);    
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);

    $regex='/href=\"\/txt\/[0-9].*/';
    preg_match_all($regex,$result,$parts);

    foreach($parts[0] as $link){
        $url = 'http://zedge.net' . str_replace ("href=\"",'',$link);
        echo file_get_html($url)->plaintext; 
        echo "<br /><br /   ><br />";
    }

    curl_close($ch);    
    echo $html->find('displaybody', 0)->innertext;      
?>
  • 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-31T03:51:43+00:00Added an answer on May 31, 2026 at 3:51 am

    The error means your script is taking too long to execute, so it is shut down. If the fetching of the pages just takes a long time and this is no problem, you can disable or increase the max. execution time with set_time_limit(). It’s also possible that a bug is causing your script to be stuck for too long on a single part, if you suspect this is the case you should measure the time at different parts of your script to see what’s causing the script to hang.

    As for your other issue, you want to get the div#displaybody contents from every individual page? Assuming the URL extraction is already working, I suppose you could do that by doing this inside the foreach loop:

    $html = file_get_html($url);
    $displaybody = $html->find('div[id=displaybody]', 0)->plaintext;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I having trouble cause I am fetching some text from the db(mysql), that text
Having trouble getting my POST arrays to show all checkbox values from my form.
First of all thank you for reading this. I am having some trouble fetching
I'm having trouble fetching the index of another field from jquery .each() function. I
Having trouble with checkboxes that are being pre-checked (when fetching record from mysql). So
Having trouble getting this syntax right: SELECT DISTINCT id FROM metadata WHERE (meta_key =
Having trouble determining if a file name conforms to a specific convention as follows.
Having trouble rewriting the name of a flash file: /flash/shell.1257347618.swf (the numbers are a
Having trouble getting the oauth access token and secret exchanged from the request tokens
Having trouble grouping active forum sum results by wildcards. Ultimately, I want all the

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.