-
November 19th, 2013, 06:53 AM
#1
How to get country from webpage
Hi! Well I need to get the country automatically from code to show in my app. Well, I found this page: http://api.hostip.info/country.php which gives to you the country code like I need. But I don´t know if there are any form to get this from code. I hope someone can help me. Thanks in advance.
-
November 19th, 2013, 07:00 AM
#2
Re: How to get country from webpage
Is this a visual c++ question or a web page scripting question??
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
November 19th, 2013, 07:16 AM
#3
Re: How to get country from webpage
Visual c++ question. I only want to know if it is possible to get the country name from a web page like the one I put before or it´s impossible. Or download the content as string or txt...
-
November 19th, 2013, 08:08 AM
#4
Re: How to get country from webpage
How is it a Visual C++ question?
-
November 19th, 2013, 08:17 AM
#5
Re: How to get country from webpage
Originally Posted by varis
Visual c++ question. I only want to know if it is possible to get the country name from ...
May I ask you why you need it?
Victor Nijegorodov
-
November 20th, 2013, 06:09 AM
#6
Re: How to get country from webpage
Originally Posted by VictorN
May I ask you why you need it?
For my app. I have a label who tell the country of the user and I want to get from that page but I don´t know how to.
Right, it´s a visual C++ question, I´m using c++ on visual studio 2010. I can´t understand why people still thinking that I´m not using c++ xD, and why is important.
-
November 20th, 2013, 06:19 AM
#7
Re: How to get country from webpage
Define "the country of the user".
And who is about to provide this information?
Victor Nijegorodov
-
November 20th, 2013, 06:30 AM
#8
Re: How to get country from webpage
Well, in that page, tells you the country (in this form: US, UK, ES...) where you live from your ip, and I need exactly that.
-
November 20th, 2013, 08:33 AM
#9
Re: How to get country from webpage
Then use WinInet API to connect to http://api.hostip.info/country.php or any similar site to obtain country name.
Or you could download and then use the database containing country names with the IP Addresses:
http://www.developerfusion.com/artic...ddress-how-to/
Victor Nijegorodov
-
November 21st, 2013, 01:58 AM
#10
Re: How to get country from webpage
I guess, URLDownloadToFile function is the simplest way for you to get that info. Save it to some file in %TEMP% folder, and read it whenever you need it.
Best regards,
Igor
-
November 22nd, 2013, 09:03 AM
#11
Re: How to get country from webpage
Hi again. Thanks for the answers. I found URLDownloadToFile more easier to use but I have a problem. If I create a new project works perfect, but If I use on my project I have a problem with UrlMon.h.
UrlMon.h: No such file or directory
But I don´t know why I have this problem in one project and not in the other :S. I have the directory C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include in the project aswell.
Any idea?
-
November 25th, 2013, 07:16 AM
#12
Re: How to get country from webpage
Ok, was a mistake of linking librarys. All works perfect now. Thanks for the replies and help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|