We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,970 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

fetching inner text from a particular div

Hello,

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
and after 4 page successfully fetched i get an error,

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

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
include ('simple_html_dom.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;


?>
2
Contributors
1
Reply
1 Year
Discussion Span
3 Weeks Ago
Last Updated
5
Views
Xufyan
Posting Whiz
314 posts since Mar 2010
Reputation Points: 6
Solved Threads: 7
Skill Endorsements: 0

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

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

Here is the code for the script,

I think someone has an anwser/solution for the issue you are having here:

http://stackoverflow.com/questions/9556198/fetching-inner-text-from-a-particular-div

LastMitch
Industrious Poster
4,146 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0655 seconds using 2.8MB