What is some PHP code to grab updated content from body tag of another website? - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > PHP Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-14-2010, 01:48 AM   #1 (permalink)
Junior Member
 
Join Date: Aug 2010
Posts: 2
Default What is some PHP code to grab updated content from body tag of another website?

What is some PHP code to grab updated content from body tag of another website onto my own website?

For my own personal use, I want to list the content of heaps of URL's together on one page.

What I want to do is grab only the body content of bible passage from biblegateway.com into my own website page. What code would I use. I want it to show the following on my website in the following format: (go to biblegateway.com and then type Psalm 1 : 1 - 6)



Psalm 1
1 Blessed is the man
who does not walk in the counsel of the wicked
or stand in the way of sinners
or sit in the seat of mockers.
2 But his delight is in the law of the LORD,
and on his law he meditates day and night.

3 He is like a tree planted by streams of water,
which yields its fruit in season
and whose leaf does not wither.
Whatever he does prospers.

4 Not so the wicked!
They are like chaff
that the wind blows away.

5 Therefore the wicked will not stand in the judgment,
nor sinners in the assembly of the righteous.

6 For the LORD watches over the way of the righteous,
but the way of the wicked will perish.


And then below this, I would want to show the body text from the next url. This would be Psalm 2. How can I do this?
jeremypyle is offline   Reply With Quote
Sponsored Links
Old 08-14-2010, 01:54 AM   #2 (permalink)
Junior Member
 
Join Date: Aug 2010
Posts: 2
Default Re: What is some PHP code to grab updated content from body tag of another website?

For example, I want to grab only the Bible readings from the following URLS and have it show on my own website:

biblegateway.com/passage/?search=Psalm 1 : 1 - 6&version=NIV
biblegateway.com/passage/?search=Psalm 16 : 1 - 6&version=NIV
biblegateway.com/passage/?search=Psalm 16 : 7 - 11&version=NIV
biblegateway.com/passage/?search=Psalm 20 : 1 - 9&version=NIV
biblegateway.com/passage/?search=Psalm 23 : 1 - 6&version=NIV
biblegateway.com/passage/?search=Psalm 34 : 1 - 5&version=NIV
jeremypyle is offline   Reply With Quote
Old 09-13-2010, 04:07 PM   #3 (permalink)
Regular User
 
Join Date: Sep 2010
Posts: 30
Default Re: What is some PHP code to grab updated content from body tag of another website?

For this first you need to download the page and then parse that page and fetch the required text.
you can use file_get_contents(); cURL, fopen etc to download the page at the given URL.

Once downloaded you can parse it using HTML DOMDocument.

Download using this,
1.
PHP Code:
<?php
ini_set
('default_socket_timeout'10);
$url "URL";
if( 
file_get_contentsurlencode($url) ) === false ) {
   
// failure
} else {
   
// success
}
?>
Or 2.
PHP Code:
<?php
$url 
'URL';
$text content_from_curl($url);

function 
content_from_curl($url)
{
   
$content false;     // we will populate this with the downloaded content, if we get, else return false
   
$curl curl_init();
   
curl_setopt($curlCURLOPT_URL$url);
   
curl_setopt($curlCURLOPT_USERAGENT"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
   
curl_setopt($curlCURLOPT_RETURNTRANSFER1);
   
curl_setopt($curlCURLOPT_TIMEOUT2);
   
curl_setopt($curlCURLOPT_CONNECTTIMEOUT2);

   if( ( 
$content curl_exec($curl) ) === false )   {         //failure
      
echo 'cURL error: ' curl_error($ch);
   }
   else {
      
//success
   
}
   
curl_close($curl);        // close the connection
   
return $content;
}
?>
Check this out to get some idea on how to parse HTML.

Last edited by PradeepKr; 09-14-2010 at 02:02 AM.
PradeepKr is offline   Reply With Quote
Old 09-17-2010, 05:10 AM   #4 (permalink)
Junior Member
 
Join Date: Sep 2010
Posts: 16
Default Re: What is some PHP code to grab updated content from body tag of another website?

I'm not too sure sorry
Echo is offline   Reply With Quote
Reply

Tags
html codes , php code , rss , website content

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 07:59 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting