Skip to content

Instantly share code, notes, and snippets.

@jinahadam
Created December 23, 2010 12:25
Show Gist options
  • Save jinahadam/752901 to your computer and use it in GitHub Desktop.
Save jinahadam/752901 to your computer and use it in GitHub Desktop.
php haveeru scrap
<html>
<head>
<style>
div {
font-family:"A_Randhoo";
direction: rtl;
unicode-bidi: bidi-override;
}
h2 {
font-family:"A_Randhoo";
direction: rtl;
unicode-bidi: bidi-override;
}
</style>
</head>
<body>
<?php
$id =$_REQUEST['id'];
// put your code here
$url = "http://www.haveeru.com.mv/?page=details&id=".$id;
//$url = "http://www.haveeru.com.mv/?page=details&id=103214";
$raw = file_get_contents($url); //whole page
preg_match_all("|<div class='thaana'><font face='A_Faseyha' size='4'>(.*)</div>|U",$raw,$rows); //get the chunk of the file with the content
preg_match_all("|<font face='A_Waheed'>(.*)</font>|U",$raw,$title); //further refine it into an array
$realtitle = strip_tags($title[0][0]); // content at this index //remove html tags
foreach($title[0] as $value) {
if(strlen(strip_tags($value)) > strlen($realtitle)) $realtitle = strip_tags($value); //ugly way to get tag with most content. i.e body
}
$format = "<h2>".$realtitle."</h2>"."<div>".strip_tags($rows[0][0])."</div>"; //print title
echo utf8_decode($format); //print the body text
//print_r($title);
?>
</body>
</html>
@jinahadam
Copy link
Author

not the prettiest thing in the world but gets the job done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment