Jump to content

Recommended Posts

all you need to do is call the home page of the domain (assuming it's a web server). Included in the headers sent back is the info you are looking for. I'd use curl functions, but you may get away with file functions to just pull a page back and parse the headers.

I did this a while ago, and found my old code and it was like this (It was to get a weather part of weather.com), yours will be simpler probably

<?php 
if($content=file_get_contents("http://www.weather.com/outlook/recreation/outdoors/fishing/28911:21")){
$content = substr_replace($content,"",0,2000);//Strips out the first css idderation
$css_start = strpos($content,"<style type=\"text/css\">")-1;
$css_end = strpos($content,"</style>");
$css_length = $css_end-$css_start;
$css = substr($content,$css_start,$css_length);
echo $css."</style>";
$start = strpos($content,"<!-- main module -->")-1;
$end = strpos($content,"<!-- end today / tonight -->");
$length = $end-$start;
$data = substr($content,$start,$length);
}
?>

 

I broke apart the source code to what I wanted.

Yours will be like

<?php
$server = "";
if($content=file_get_contents("http://samspade.org/whois/".$server)){
$content = explode("<div class=\"set\"", $content); //This breaks it up at the start of the raw data
$data = explode("</div>",$content[1]); //This gets the end chopped off
echo $data[0];
}
?>

Then just do what you want with $data[0] to get what you want

 

this is what i've hashed out in a few minutes using the samspade result (it only does the first box, but can be modified for the second box)  it returns this array of each of the heading names so you could just pull what you need out of that

<?php
$server = "google.com";
if($content=file_get_contents("http://samspade.org/whois/".$server)){
$content = explode("<div class=\"set\"", $content); //This breaks it up at the start of the raw data
$data = explode("</div>",$content[1]); //This gets the end chopped off
$fields = array(
	"Registrant", "Domain Name", "Registrar Name", "Registrar Whois",
	"Registrar Homepage", "Administrative Contact", "Technical Contact Zone",
	"Created On", "Expires On", "Record last updated on", "Domain servers in listed order"
);
$data_2 = array();
$i = 0;
$field_count = count($fields)-1;
while(!empty($fields[$i])){
	$j = $i+1;
	$tempdata = explode($fields[$i],$data[0]);
	if($j <$field_count){
		$tempdata_2 = explode($fields[$j],$tempdata[1]);
		$temp = trim(nl2br(str_replace(": ", "", $tempdata_2[0])));
		$data_2[$fields[$i]] = $temp;
	}
	else{
		$temp = trim(nl2br(str_replace(": ", "", $tempdata[1])));
		$data_2[$fields[$i]] = $temp;
	}
$i++;
}
foreach($data_2 as $key => $value){
	echo $key.": ".$value."<br/>";
}
}
else{
echo "failed to open stream";
}
?>

I found a few small issues in the fields array causing a bit of issues which i fixed

<?php
$server = "google.com";
if($content=file_get_contents("http://samspade.org/whois/".$server)){
$content = explode("<div class=\"set\"", $content); //This breaks it up at the start of the raw data
$data = explode("</div>",$content[1]); //This gets the end chopped off
$fields = array(
	"Registrant", "Domain Name", "Registrar Name", "Registrar Whois",
	"Registrar Homepage", "Administrative Contact", "Technical Contact  Zone Contact",
	"Created ", "Expires ", "Record last updated ", "Domain servers in listed order"
);
$data_2 = array();
$i = 0;
$field_count = count($fields)-1;
while(!empty($fields[$i])){
	$j = $i+1;
	$tempdata = explode($fields[$i],$data[0]);
	if($j <=$field_count){
		$tempdata_2 = explode($fields[$j],$tempdata[1]);
		$temp = trim(nl2br(str_replace(": ", "", $tempdata_2[0])));
		$data_2[$fields[$i]] = $temp;
	}
	else{
		$temp = trim(nl2br(str_replace(": ", "", $tempdata[1])));
		$data_2[$fields[$i]] = $temp;
	}
$i++;
}
foreach($data_2 as $key => $value){
	echo $key.": ".$value."<br/>";
}
}
else{
echo "failed to open stream";
}
?>

 

It still needs some work like cleaning up the created on register on modified on fields, and the nameserves to remove the ad space, and also it needs to be turned into a function rather than the static code, but  I think u got the idea.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.