Jump to content


Photo

Pinging and grabbing info from a website..


  • Please log in to reply
2 replies to this topic

#1 ChambeRFienD

ChambeRFienD
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 13 June 2006 - 07:41 PM

I've heard of people being able to pull text from a website using fopen or something of the sort, but I'm looking to write a little PHP program to make my job go a bit faster at work. (We deal with a lot of domain names)

I was wondering if there was a way to ping a website with PHP and return the IP address of that site. I'm also looking for a way to pull the title from a website and return that if possible. Anyone have any ideas that could help me out?

#2 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 13 June 2006 - 07:49 PM

@php.net:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Example 1. A simple gethostbyname() example
<?php
$ip = gethostbyname('www.example.com');

echo $ip;
?>
[/quote]

z..z..z..z..z..z..z..z..

#3 ChambeRFienD

ChambeRFienD
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 13 June 2006 - 07:58 PM

[!--quoteo(post=383437:date=Jun 13 2006, 03:49 PM:name=joquius)--][div class=\'quotetop\']QUOTE(joquius @ Jun 13 2006, 03:49 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
@php.net:
[/quote]

Thanks much for that.. A lot easier than what I was thinking. I was heading more towards the system() function. =x

Using this now:

<?
$host = 'lkasdflkawefhasdh.com';
$ip = gethostbyname($host);
if($ip == $host) {
    echo "Unable to find host.";
} else {
    echo $ip;
}
?>


Now to grab the titles from websites..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users