How do I crawl an IP address and get list of websites on it in PHP?
Let's say I have an IP address for a specific web server say it's 67.222.134.101, how do I get a list of all开发者_开发百科 the websites on that web server using PHP?
The most common way to do this is to run a full-scale web crawler, which harvest domain names and check which IP addresses they point to. That way, you can map the IP addresses to domains you've found.
It's impossible. Although there is a workaround: there are some websites which collects the reverse names of an IP address. If your ip is collected by one of these sites, you can crawl the list from them. Ofcourse after you got a permission to clone their database.
Example: http://www.yougetsignal.com/tools/web-sites-on-web-server/
Building on Eduard7's answer, you can use DNS tools to look up a DNS name from an IP address.
Keep in mind, this does NOT list all web sites at that address; it is only listing domain names that are registered with PTR records. So it may not include all web sites or even any web sites at all. It may also include domain names that do not have web sites associated with, e.g. if a domain name is ftp.mydomain.com, we probably wouldn't find a website with that name.
Anyhow, with those caveats, here's how you use dig
(Linux or Unix) to look up domain names from an IP address:
/Users/mhaase $ dig -x 67.222.134.101
; <<>> DiG 9.8.1-P1 <<>> -x 67.222.134.101
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43186
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;101.134.222.67.in-addr.arpa. IN PTR
;; ANSWER SECTION:
101.134.222.67.in-addr.arpa. 43200 IN PTR 67.222.134.101.tailormadeservers.com.
;; Query time: 106 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Tue Aug 21 10:14:22 2012
;; MSG SIZE rcvd: 95
精彩评论