Hack Forums
[.NET] Mini IP Tool problem with Geo IP - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Mini IP Tool problem with Geo IP (/showthread.php?tid=5064389)



Mini IP Tool problem with Geo IP - BigMre - Nov 20, 2015

Whats Up,

i have a Problem with my code.

i have a textbox to enter an ip then one for the output and a Button to Start.

the Code looks like this:

Code
Private Sub geoip_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles geoip.KeyDown
        If e.KeyCode = Keys.Enter Then
            e.SuppressKeyPress = True
            geoausgabe.Text = ""
            WebRequest.Create("www().api.()com/()()geoip.Text)
            geoausgabe.Text = New System.Net.WebClient().DownloadString("www().api.()com/()()geoip=" + geoip.Text)

the output of the api is in a HTML Format, so the output text has <br> in it.

is there a way to transform the <br> into next line (\n) that the output is orderd :D


Thanks..


ps: i will publish my Programm. It has a Skype Resolver and other cool tools in it :D


* - Odus - Nov 20, 2015

(Nov 20, 2015 05:15 AM)BigMre Wrote:  
Code
WebRequest.Create("www().api.()com/()()geoip.Text)
geoausgabe.Text = New System.Net.WebClient().DownloadString("www().api.()com/()()geoip=" + geoip.Text)

You're gonna have to pick one.

As for your question, easy way is to call Replace and replace "<br />" or whatever with string.Empty.


* - BigMre - Nov 20, 2015

öhm i have a api.. i just censored it.


but i do not really know how to do this


* - nathan72389 - Nov 20, 2015

(Nov 20, 2015 05:47 AM)BigMre Wrote:  öhm i have a api.. i just censored it.


but i do not really know how to do this

holy shit, string manipulation is something that you learn 101 style, not a fucking skype, ip, web anything.

this is VERY VERY VERY basic.


* - log dot zip - Nov 20, 2015

Hoping that other less novice programmers stumble upon this thread in the future, I'll post something I made a while back for another user on here.

[Image: ZtOVvV3.png]

Example using the API provided by https://freegeoip.net

[Image: 3ANqP5w.png]


* - Odus - Nov 20, 2015

(Nov 20, 2015 07:36 AM)codeconfusion Wrote:  Hoping that other less novice programmers stumble upon this thread in the future, I'll post something I made a while back for another user on here.

-snip

Or copy the response, go to VS and Edit -> Paste Special -> Paste XML As Classes, then deserialize if you want everything:

Code
var ip = Console.ReadLine();

Response response = null;
var serializer = new XmlSerializer(typeof(Response));
            
using (var wc = new WebClient())
using (var sr = new StringReader(wc.DownloadString($"https://freegeoip.net/xml/{ip}")))
    response = (Response)serializer.Deserialize(sr);

Console.WriteLine(response.CountryName);
Console.ReadLine();

If you're printing everything, override ToString and build it there.


* - ItsBryanTho - Nov 20, 2015

turn option strict on
it always catches those weird errors