Created
December 23, 2010 12:25
-
-
Save jinahadam/752901 to your computer and use it in GitHub Desktop.
php haveeru scrap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not the prettiest thing in the world but gets the job done.