TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   get all text in div (http://www.talkphp.com/advanced-php-programming/4879-get-all-text-div.html)

russellharrower 08-20-2009 03:23 AM

get all text in div
 
Hi just windering we need to get all the html code inside the following div using a php script

Code:

<body>
<div id="entry"></div>
</body>

the page is on another server, and we don't have access to the ftp and it changes every 2 hours, so I was thinking using a ping file that runs every 2 hours, (I would set that up in cpanel)

the file url looks like
http://www.example.com/blog.php

Thanks

maZtah 08-20-2009 07:54 AM

Take a read on this one: http://nl.php.net/manual/en/function.file.php !

gamer13 09-01-2009 02:40 PM

Try this:

PHP Code:

<?php
$ch 
curl_init();

curl_setopt($chCURLOPT_URL"http://www.example.com/blog.php");
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);

$content curl_exec($ch);
if (
preg_match('/<div(.*?)>(.*?)<\/div>/is'$content$matches) {
    echo 
$matches[2];
} else {
    echo 
'Nothing found!';
}

So consider you have this page:
Code:

<html>
<head>
    <title>Some title</title>
</head>
<body>
    <div id="entry">Some random text</div>
</body>
</html>

Then the PHP script will output: "Some random text".


All times are GMT. The time now is 10:37 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0