Jun 20, 2015 07:47 PM
(This post was last modified: Jun 22, 2015 04:03 PM by Vysse.)
So I needed a working version of the get flag from IP so I updated the code from ubbelol's post years ago. Here is the code. Credits to ubbelol for the original code.
For those wondering why I used String.Remove instead of Regex the reason is Regex wasn't working properly for what I wanted to do and I couldn't figure out why so I went with a method I knew would work.
Code
Private Function retFlag(ByVal IP As String) As Image
Dim srcReq As WebRequest = WebRequest.Create("http://geoiptool.com/en/?IP=" & IP)
Dim srcRes As WebResponse = srcReq.GetResponse()
Dim src As String = New StreamReader(srcRes.GetResponseStream()).ReadToEnd()
Dim imgLoc As String = Regex.Split(Regex.Split(src, "<img src=""")(3), """")(0)
imgLoc = imgLoc.Remove(0, 2)
Dim picReq As WebRequest = WebRequest.Create(String.Concat("http://geoiptool.com", imgLoc))
Dim picRes As WebResponse = picReq.GetResponse()
Return Image.FromStream(picRes.GetResponseStream())
End FunctionFor those wondering why I used String.Remove instead of Regex the reason is Regex wasn't working properly for what I wanted to do and I couldn't figure out why so I went with a method I knew would work.


