How to get country from webpage
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Thread: How to get country from webpage

  1. #1
    Join Date
    Nov 2013
    Posts
    6

    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.

  2. #2
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,396

    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. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  3. #3
    Join Date
    Nov 2013
    Posts
    6

    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...

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,098

    Re: How to get country from webpage

    How is it a Visual C++ question?

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,392

    Re: How to get country from webpage

    Quote Originally Posted by varis View Post
    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

  6. #6
    Join Date
    Nov 2013
    Posts
    6

    Re: How to get country from webpage

    Quote Originally Posted by VictorN View Post
    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.

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,392

    Re: How to get country from webpage

    Define "the country of the user".
    And who is about to provide this information?
    Victor Nijegorodov

  8. #8
    Join Date
    Nov 2013
    Posts
    6

    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.

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,392

    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

  10. #10
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,978

    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

  11. #11
    Join Date
    Nov 2013
    Posts
    6

    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?

  12. #12
    Join Date
    Nov 2013
    Posts
    6

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center