Nu har jag suttit i flera timmar och försökt få fram data ur en sida men inte lyckats... Jag vet dock att jag hämtar sidan korrekt. men sen när jag skall plocka ut data förstår jag nada ...
Kan ingen hjälpa mig att komma igång?
Jag har sidan:
http://www.dnsstuff.com/tools/city.ch?ip=81.231.240.208
Jag vill plocka ut det som står bredvid Country, City, Country Code och Currency. Jag försöker plocka ut data en åt gången...
Kod som fungerar
Function GetISP(strIP)
If InStr(strIP, ".") = 3 Then
Set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objHTTP.Open "GET", "http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=" & strIP & "&do_search=Search", False
objHTTP.Send
strHTML = objHTTP.ResponseText
Set objHTTP = Nothing
With New RegExp
.IgnoreCase = True
.Global = False
.Pattern = "descr:[^\n]+"
For Each Match In .Execute(strHTML)
strMatch = Trim(Mid(Match.Value, 7))
Next
End With
GetISP = strMatch
Else
GetISP = "No valid IPv4"
End If
End Function
Kod som inte fungerar (annan sida). men borde vara samma ändå??
Function GetCountryCode(strIP)
If InStr(strIP, ".") = 3 Then
Set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objHTTP.Open "GET", "http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=" & strIP & "&do_search=Search", False
objHTTP.Send
strHTML = objHTTP.ResponseText
Set objHTTP = Nothing
With New RegExp
.IgnoreCase = True
.Global = False
.Pattern = "Country:[^\n]+"
For Each Match In .Execute(strHTML)
strMatch = Trim(Mid(Match.Value, 8))
Next
End With
GetCountryCode = strMatch
Else
GetCountryCode = "No valid IPv4"
End If
End Function
Jag anropar funktionerna med:
<%
strIP = Request.ServerVariables("REMOTE_HOST")
Response.Write(GetISP(strIP))
Response.Write(GetCountryCode(strIP))
%>