Html code, need help and advice.

You can use iframe and embed the other webpage onto your site. Works wonderfully well in some cases...
 
hey guys, been getting a few PMs about this, will be better for everyone if we keep it here in the topic so others can help/learn as well ;)

if u have access to cURL, you can use the following code:
Code:
curl "http://site-to-copy.com/page.html" -o /path/to/output-filename.html -A "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30" --connect-timeout 30;

To use it:
1. Replace http://site-to-copy.com/page.html with the full address of the page u want to download
2. Replace /path/to/output-filename.html with the full directory address of the file and name u want to save it as on ur storage system
3. Optional: Replace the User Agent string with a browser of ur choice
4. Set up a CRON job (if u have access) to execute the script at intervals to suit ur needs

Done! This is a very simple example and u can expand on it to suit ur needs ;)
 
Ok, here is an little exemple:
I choose this page: h t t p : / / e n . w i k i p e d i a . o r g / w i k i / N e w s. Let's say that we want to take the content from Etymology paragraph.
First make a new PHP file called "getpagesource.php"(or whatever you want, doesn't matter the name) and a new .txt file called "pagesource.txt".
In it add the next code:
PHP:
$ch = curl_init(" h t t p : / / e n . w i k i p e d i a . o r g / w i k i / N e w s"); // here we  initializes a new curl session and we add the url from where we want to  get the content. mine is
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($ch);//here we execute the given cURL session, take the page source code and store it in variable $content
$open=fopen('pagesource.txt',w) or exit("Unable to open file!");//we open the pagesource.txt file
fwrite($open, $content);//here we write the page source code from $content into our pagesource.txt file which was made earlier.
fclose($open);//close the file
Upload this files on you're host and run the script once (from h t t p : / / y o u r e d o m a i n . n e t / g e t p a g e s o u r c e . p h p ). Now open the pagesource.txt you will see that the page source from h t t p : / / e n . w i k i p e d i a . o r g / w i k i / N e w s is stored there.
After this we will make an new PHP file named "displaycontent.php" where we will add next code:
PHP:
$file = file_get_contents("pagesource.txt", true);//get the content of pagesource.txt file

function get_string_between($string, $start, $end){
    $string = " ".$string;
    $ini = strpos($string,$start);
    if ($ini == 0) return "";
    $ini += strlen($start);
    $len = strpos($string,$end,$ini) - $ini;
    return substr($string,$ini,$len);
}
//this function will return the string between two tags :)

$content= get_string_between($file, '<span class="mw-headline"  id="Etymology">Etymology</span></h2>', '<sup id="cite_ref-1" class="reference">< a href="#cite_note-1"><span>[</span>2<span>]</span></a></sup>');
//To get the content we need two delimiters.
//So you see that our  Etymology paragraph(from here: h t t p : / / e n . w i k i p e d i a . o r g / w i k i / N e w s) it  start with "One theory is that news.." and ends with "..the cardinal  directions: north, east, west, and south". Ok, now go to our  pagesource.txt and search these two strings. Our delimitors will be the  tags before "One theory is that news.."(which is <span  class="mw-headline" id="Etymology">Etymology</span></h2>)  and the tags after the "..the cardinal directions: north, east, west,  and south" (in our case "<sup id="cite_ref-1" class="reference">< a href ="#cite_note-1"><span>[</span>2<span>]</span></a></sup>"). You can choose whatever delimitors you want. :D

echo $content; // print the result
Now upload this script on you're host and run it. It should display our wanted content.
For cronjobs, you should have into you're hosting cpanel a section called CronJobs or CronTab something like this. Go there and into the execute command put "wget h t t p : / / y o u r e d o m a i n . n e t / g e t p a g e s o u r c e . p h p " and set it to 5min time between executions. Now the "getpagesource.php" it should be executed every 5minutes.

Hope you will understand what i want to say. :) Post here if encounter problems.
 
hey guys, been getting a few PMs about this, will be better for everyone if we keep it here in the topic so others can help/learn as well ......
Done! This is a very simple example and u can expand on it to suit ur needs ;)

Ok, here is an little exemple:
I choose this page: h t t p : / / e n . w i k i p e d i a . o r g / w i k i / N e w s. Let's say that we want to take the content from Etymology paragraph.
First make a new PHP file called "getpagesource.php"(or whatever you want, doesn't matter the name) and a new .txt file called "pagesource.txt".
In it add the next code....

guys, really thanks alot!!! I manage to get the script up and use already!

thanks for sharing your experience

THANK YOU SO MUCH !!:D
 
Back
Top