Program.in

By Santosh Wadghule

My Blog Fetcher…

leave a comment »

Blog fetcher is program in PHP that i have made to fetch my blog heading titles (topics) and also the dates and categories. But this program is applicable only for my particular blog not for other blogs. So that I have used file handling for reading data of My blog. Blog fetcher is similar to the concept of RSS , But still it is not RSS. It catches the html tags of my blog and reads data of that tag and prints the data. Output is bellow…

php code is bellow :


$source = "http://programin.wordpress.com/";
$file = fopen("$source", "r") or exit("Unable to open file!");
while(!feof($file))
{
$line = fgets($file);
if($pos1 = strpos($line , "h2" )) //for catching the blog post titles
{
echo $line;

}
else if($pos2 = strpos($line,"meta"))  //for catching the dates and categories
{

echo $line;
}

}
fclose($file);
?>


I have used css for attractive output. Code of css is bellow :


html,body{margin:0.5%;padding:0}
div#header h1{

height:80px;margin:0;
border-bottom:2px solid #00529B;
border-top:2px solid #00529B;
border-left:2px solid #00529B;
border-right:2px solid #00529B;
background: #BDE5F8;
padding-left:5px;
font-family :'Trebuchet MS';
color : #00529B;
}

h2{ font-family :'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
font-size: 15pt;
color: green;
text-align: left;
margin-top: 0.5%;
}

div#container{
border-bottom:2px solid #00529B;
border-top:2px solid #00529B;
border-left:2px solid #00529B;
border-right:2px solid #00529B;
padding:4px 6px;
width:800px;
margin:0 auto
}

div#content{padding-left:5px; margin-top:3%}

.meta {
border-bottom: 1px dotted #00529B;
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
color:black;
padding:4px 6px;
margin:0 0 10px 0;
}

a:link {color: #00529B}
a:visited {color:gray}
a:hover {color:green;font-size: 100%}
a:active {color:black}
a {text-decoration: none}

span.small {
color : green;
font-size:15px;
}

Written by Santosh Wadghule

May 24, 2008 at 5:39 am

Posted in PHP, Uncategorized

Leave a Reply