Results 1 to 2 of 2
Hi,
I just want to copy the content from Wikipedia. Daily i want to do it. But this should be done automatically. can anyone tel me how to do this ...
- 02-01-2011 #1Linux User
- Join Date
- Aug 2008
- Location
- Trichy,India
- Posts
- 308
How to copy the article from wiki using php
Hi,
I just want to copy the content from Wikipedia. Daily i want to do it. But this should be done automatically. can anyone tel me how to do this in php? is there any function to copy the content of any article?Thanks in advance...
- 02-01-2011 #2Linux Newbie
- Join Date
- Dec 2009
- Posts
- 241
You will need a little more ...
like:
fopen
fread / fget
str_replace
stristr
strip_tags
And another Tip:
"\n" will produce a new line.
A example would be:
you would write the info like that into a file:PHP Code:$page = fopen("http://blabla.net?info=2wq", "r");
$echo = false;
$start=explode("\n", "Headline1
Headline2
Headline3");
$stop[] = "</h4>";
while (($line = fget($page))!=""){
if ($echo) foreach ($stop as $search)
if (stristr($line, $search) != false) {
$echo = false;
}
if (!$echo) foreach ($start as $search)
if (stristr($line, $search) != false) {
$echo = true;
}
if ($echo) {
$line = str_replace("<br>", "\n", $line); //<br> marks a newline
// ... other replacements ... of html tags
$line = str_replace("</td>", "\t", $line); //</td> marks end of cell in table
$line = str_replace("</tr>", "\n", $line); // </tr> marks end of row in table
$line = strip_tags($line);
echo $line;
}
}
fclose($page);
an example on howto run this in time intervals would be a crontab entryCode:php example.php > filename.txt 2>/dev/null
Hope that works ... haven't tried ...


Reply With Quote