First off, I guess some people will tell me "Use google you f*cking twat." But I've tried googling and watching tutorials and stuff but I just don't get it. Also, sorry for being extremely confusing. PM for my skype name and I'll try to explain better there if you are willing to help me.
Hey! I want to try learn removing certain string from websites source code and maybe add some GeoIP feature to some program in the future. So I wanted to try to use freegeoip.com and get the info from the IP entered in my application and add it to a listbox. The source code of the info from freegoip.com is basically
Code <IP>*ip*</IP>
<CountryCode>*countrycode*</CountryCode>
<CountryName>*countryname*</CountryName>
etc
And I would like it for my program to remove the "<IP> </IP>" etc and only show the IP and all the other info. I've looked into regex and watched a few tutorials on YouTube and also checked out Shockwaves simple regex tutorial here. But I just don't understand it. I don't really know how to explain how I'm not understanding either. The tutorials I've seen get something like for example movie titles and split out the title only. But then the code of the website for the titles are always the same but with a different movie title and they can simply use a For Each statement. But in my case it's all different for example
Code <IP>*ip*</IP>
<City>*cityname*</City>
Instead of like
Code <title="Star Wars">
<title="Total Recall">
Or whatever. I'm sorry how fricking confusing this is. I can barley explain the issue myself. Maybe if someone would like to help me you could add me on Skype and I'll try to explain there. PM me for that. Sorry for being all retarded and shit. I'm not that good at VB.NET and I'm slightly dumb at times.
DO NOT DEAL WITH THIS MEMBER
Jul 27, 2015 04:26 AM
(This post was last modified: Jul 27, 2015 04:26 AM by LUOIdeRentA.)
If you'd like to learn regex, there are various websites that can help you out, such as these:
Code https://regex101.com/
http://regexr.com/
If you go to the 2nd website and on the left hand side click "Cheatsheet", it shows you all that you can do with regex and explains what all the characters do. For the example that you provided:
You can simple use this regex pattern:
But, you can do the pattern properly so that it only searches for digits instead of every character like I did. Anyway, I hope this all helps.
(Jul 27, 2015 03:51 AM)ninen2001 Wrote: So I wanted to try to use freegeoip.com and get the info from the IP entered in my application and add it to a listbox. The source code of the info from freegoip.com is basically
There is an alternative method you can use for getting information about the IP address that is entered in your application.
Code Private Sub button1_Click(sender As System.Object, e As System.EventArgs) Handles button1.Click
WebRequest.Create("htt p://api.predator.wtf/ip2loc/?arguments=" + txt1.Text)
listbox1.additem = New System.Net.WebClient().DownloadString("htt p://api.predator.wtf/ip2loc/?arguments=" + txt1.Text)
End Sub
textbox1 would have the ip address you want to resolve
listbox1 would then display the results, you can use a textbox instead.
(Jul 27, 2015 05:21 AM)janko128 Wrote: There is an alternative method you can use for getting information about the IP address that is entered in your application.
Code Private Sub button1_Click(sender As System.Object, e As System.EventArgs) Handles button1.Click
WebRequest.Create(htt p://api.predator.wtf/ip2loc/?arguments= + txt1.Text)
listbox1.additem = New System.Net.WebClient().DownloadString(My.Settings.locationapi + txt1.Text)
End Sub
textbox1 would have the ip address you want to resolve
listbox1 would then display the results, you can use a textbox instead.
What is with the random "WebRequest.Create" which isn't used, why is a string not in "" and what has this got to to with OPs question?
(Jul 27, 2015 05:25 AM)Josh Wrote: What is with the random "WebRequest.Create" which isn't used, why is a string not in "" and what has this got to to with OPs question?
Yeah i wrote this out on the thread and not on visual studio i missed the ""
(Jul 27, 2015 05:30 AM)janko128 Wrote: Yeah i wrote this out on the thread and not on visual studio i missed the ""
What's the point of the web request, seeing as you just use a web client to get the string
DO NOT DEAL WITH THIS MEMBER
Here's the actual way to do it. Of course, if you want more detailed info, just head to the API and look at the name for the values and add them yourself.
Jul 27, 2015 06:38 AM
(This post was last modified: Jul 27, 2015 06:56 AM by ninen2001.)
DO NOT DEAL WITH THIS MEMBER
Now that I saw the options on the website, you could also use JSON if you prefer that.
Jul 27, 2015 07:18 AM
(This post was last modified: Jul 27, 2015 07:18 AM by ninen2001.)
(Jul 27, 2015 07:15 AM)LUOIdeRentA Wrote: Now that I saw the options on the website, you could also use JSON if you prefer that.
I have tried JSON before but I never understood it and my brain died after like 10 minutes of trying. XML was easier.
(Jul 27, 2015 07:15 AM)LUOIdeRentA Wrote: Now that I saw the options on the website, you could also use JSON if you prefer that.
I have tried JSON before but I never understood it and my brain died after like 10 minutes of trying. XML was easier.
Jul 27, 2015 07:56 AM
(This post was last modified: Jul 27, 2015 07:58 AM by ShittyAdvice.)
(Jul 27, 2015 07:18 AM)ninen2001 Wrote: I have tried JSON before but I never understood it and my brain died after like 10 minutes of trying. XML was easier.
I have tried JSON before but I never understood it and my brain died after like 10 minutes of trying. XML was easier.
No offense but if you're serious about learning to program I'd say learning JSON is a "must".
Obviously depending on what your goals are, but JSON is used so much it'll only come in handy if you learn it, especially when you're planning on working with API's which most of the time are limited to JSON.
(Jul 27, 2015 07:56 AM)ShittyAdvice Wrote: No offense but if you're serious about learning to program I'd say learning JSON is a "must".
Obviously depending on what your goals are, but JSON is used so much it'll only come in handy if you learn it, especially when you're planning on working with API's which most of the time are limited to JSON.
I am not serious about it though. I just do it for fun and if I'm bored and maybe make a program that helps me in some way. But I should still learn it. I just never found any good tutorials or anything.
DO NOT DEAL WITH THIS MEMBER
(Jul 27, 2015 07:56 AM)ShittyAdvice Wrote: No offense but if you're serious about learning to program I'd say learning JSON is a "must".
Obviously depending on what your goals are, but JSON is used so much it'll only come in handy if you learn it, especially when you're planning on working with API's which most of the time are limited to JSON.
Absolutely this. Don't worry if you don't completely understand it either, there are tools (some right within VS itself) which can make using JSON a no brainer.
(Jul 27, 2015 06:07 AM)log dot zip Wrote: -snip
Enjoying C# 6.0's new string interpol I see haha
I may look into JSON later. It seems that alot of APIs use it such as VirusTotal. If someone could link me to a tutorial that would be great.
|