Jump to content

Archived

This topic is now archived and is closed to further replies.

ChambeRFienD

Pinging and grabbing info from a website..

Recommended Posts

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?

Share this post


Link to post
Share on other sites
@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]

Share this post


Link to post
Share on other sites
[!--quoteo(post=383437:date=Jun 13 2006, 03:49 PM:name=joquius)--][div class=\'quotetop\']QUOTE(joquius @ Jun 13 2006, 03:49 PM) [snapback]383437[/snapback][/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:

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


Now to grab the titles from websites..

Share this post


Link to post
Share on other sites

×

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.