Skip to content

Instantly share code, notes, and snippets.

@kayalshri
Created September 10, 2014 06:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kayalshri/e9ea958b0232336140a9 to your computer and use it in GitHub Desktop.
Save kayalshri/e9ea958b0232336140a9 to your computer and use it in GitHub Desktop.
Get IT Books INFO
<?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