Created
September 10, 2014 06:00
-
-
Save kayalshri/e9ea958b0232336140a9 to your computer and use it in GitHub Desktop.
Get IT Books INFO
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
<?php | |
ini_set('display_errors',1); | |
error_reporting(E_ALL); | |
$id = $_GET['id']; | |
$url="http://it-ebooks.info/book/$id/"; | |
$ch = curl_init($url); | |
$options = array( | |
CURLOPT_RETURNTRANSFER => 1, | |
); | |
curl_setopt_array( $ch, $options ); | |
$response = curl_exec($ch); | |
curl_close($ch); | |
$lines = array(); | |
$lines = explode("\n", $response); | |
$books = array(); | |
$books['id'] = $id; | |
// display file line by line | |
foreach($lines as $line_num => $line) { | |
if($line_num == 76 ){$books['title'] = strip_tags($line);} | |
if($line_num == 98 ){$books['description'] = strip_tags($line);} | |
if($line_num > 101 and $line_num<110){ | |
List($key,$val) = explode(":",strip_tags($line)); | |
$books[trim($key)] = $val; | |
} | |
if($line_num == 112 ){ | |
$keywords = preg_split("/\"/", $line); | |
$download_url = "http://it-ebooks.info".$keywords[3]; | |
$books['download'] = $download_url; | |
} | |
} | |
print "<pre>"; | |
print_r($books); | |
print "</pre>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment