Sorry, this may come across as a bit vague but how would go about and displaying a different logo of an organisation based on where the site is opened from. For example, the organisation would want their official South African logo to be displayed when the site is opened in South Africa, and another official logo when it is opened in Kenya or Ghana for example.
Would the site simply have to be hosted in more than one server...can't think of any other possible way?
To find country first you find Ipaddress
string Ipaddress= HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
Using Ip address you can find location as follows
using (var wc = new WebClient())
{
string output = wc.DownloadString(String.Format("http://api.hostip.info/?ip={0}&position=true", ipaddress));
}
Output is in XML format and it will contain a countryName tag
I would have this as a comment .Since, I don't have enough reputations, I am posting as an answer.
This link would be useful to detect the country and change the logo based on the country in your logic.
Detect/estimate country of a http-request in ASP.NET
Adding the contents of the link, since the link may expire.
You can use one of available web services to match an incoming request to a country.
Otherwise you may decide to grab the MaxMind database file (GeoLite Country), read from this file in your application and perform a match. Thus you will be independent from a third-party service, only pulling regularly updates for the database file.
Also check out similar questions:
Geolocation web service recommendations
Know a good IP address Geolocation Service?
In a very short, in market so many vendors are there, who are tracking geolocation, One of them is google API.
https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_API_KEY
You can generate your own API_KEY.
Hope this post will helps you. :)
Related
I'm not really sure how to frame the question (maybe the reason why I could not find the answer, so please let me know if it's duplicated question) but I'm not able to get the exact address for a website that I want to scrape. The website address is "https://www.nysar.com/find-a-realtor/". And I want to only scrape information in Albany, NY. And when I search by the address with Albany, NY, I get new search results but the URL is still the same....
Is there any way that I can find out the detailed URL address?
Thank you in advance!
That page is dynamically loaded using javascript, so in order to see the source of your search result, you have to go into the Developer tools of your browser and look for it under Network/XHR. There's a lot of information about this, including here. It's not a simple concept so you should study up on it before attempting to scrape this type of sites.
In any event, in this particular case, the data is extracted from here.
Is there a library or service that returns the US federal congressional district given a US address?
You can do this on govtrack.us. I am not sure if there is a code framework for this, but you could probably write one from this information.
Full disclosure - I work for a company that also provides congressional district data - smartystreets.com
Keep in mind that this information changes often and I have been looking for the last 4.5 years and haven't yet pinpointed an actual, absolutely reliable source for this data. All of the companies I have looked at, including mine, say that their source is the US Postal Service but no one in the US Postal Service has been willing to tell me how frequently the data is updated within their system and what their source might be. So, just be aware.
I'm one of the creators of Geocodio and we had this problem ourselves. So we made it part of our geolocation tools!
You can use the Geocodio API or spreadsheet upload to look up Congressional districts, Representative/Senator contact information, etc. Docs: https://www.geocod.io/docs/#congressional-districts
You can use the Sunlight Foundation Congress API, which is free to use. Go to: http://tryit.sunlightfoundation.com/congress You can determine congressional district by zipcode (not completely reliable since zipcodes can traverse multiple districts) or by latitude/longitude. Just use Google geocoding to retrieve lat/lng from your address, and then you can look up the congressional district.
The whoismyrepresentative.com/api site can translate a zipcode into a congressional district. You can do a call with the url below, replacing 10038 with your zipcode.
http://whoismyrepresentative.com/getall_mems.php?zip=10038&output=json
Hope that helps!
**Also note that the sunlightfoundation site returns a 404 error and govtrack.us does not have an api for searching for congressional districts.
How do I go about displaying content based on a users location ? For ex. If somebody accesses the site from the New York , I would like to display New York Hotels . However if somebody accesses the site from Chicago , I would like to display Chicago hotels.
You're looking for a Geoloction database which would give you access to the typical IP ranges for the countries/cities you need to flag.
This is not absolute or completely trustworthy information though. Country level geo-location is mostly effective but anything like city/state/zip code level information should be treated with great caution.
I've worked with major multinational media providers using expensive paid services and discovered that the information in these databases is a very long way from correct and that users individual circumstances often prevent geo-location from being effective.
e.g. Virgin and East Coast trains in the UK use T-Mobile Germany as their onboard internet provider so you appear to be in Germany to many sites and payment processors.
There are quite a few free geolocation databases, MaxMind springs to mind (though this is not a recommendation of their service).
You can find some thoughts on implementing geo-location here
You need some database/api with information about hotells in different locations, then you need to now where the visitor is.
You can use something like Travel/Hotel API's? to find hotells.
And for finding the location of your visitor you can use something like http://www.hostip.info/use.html
or you can use HTML5 geolocation api example http://html5demos.com/geo . The bad thing with the html5 geo api is that the user need to accept before you get their location.
Remember that there is no guaranty that the location is correct...
This is the exact reason I created wpgeocode. WPGeocode is a free plugin for wordpress that enables publishers to customize content based on reader location. Check out the plugin at the support site at http://www.wpgeocode.com
The plugin enables shortcodes that can be placed in your posts or pages. There are many conditional shortcodes such as [wpgc_is_country_code country_code="US"] for this exact purpose. Simple open the shortcode, specify the target country_code and provide the content to be displayed if the reader is visiting from that specific country.
Visit http://www.wpgeocode.com/shortcodes for a complete listing - here are a few:
[wpgc_is_city_and_state city=”Yardley” state_code=”PA”]
[wpgc_is_ip” ip=”xx.xx.xx.xx”]
[wpgc_is_ips” ip=”xx.xx.xx.xx,aa.bb.cc.dd”]
[wpgc_is_not_ip” ip=”xx.xx.xx.xx”]
[wpgc_is_not_ips” ip=”xx.xx.xx.xx,aa.bb.cc.dd”]
[wpgc_is_city” city=””]
[wpgc_is_cities” cities=”city one,city two,city three”]
[wpgc_is_not_city” city=””]
[wpgc_is_not_cities” cities=”city
one,city two,city three”]
[wpgc_is_nearby”] – Uses the value you
specify in the Nearby Range setting from the administrative panel
[wpgc_is_not_nearby”]
[wpgc_is_within” miles=”10″]
[wpgc_is_within
kilometers=”12″]
[wpgc_is_country_name” country_name=””]
[wpgc_is_country_names” country_name=”United States,Egypt,Albania”]
[wpgc_is_country_code” country_code=””]
[wpgc_is_country_codes”
country_codes=”US,GB,AZ”]
[wpgc_is_state_code” state_code=””]
[wpgc_is_state_codes” state_codes=”PA,NJ,TX”]
[wpgc_is_not_country_name” country_name=””]
[wpgc_is_not_country_names” country_names=”United
States,Egypt,Albania”]
[wpgc_is_not_country_code” country_code=””]
[wpgc_is_not_country_codes” country_codes=”US,GB,AZ”]
[wpgc_is_not_state_code” state_code=””]
[wpgc_is_not_state_codes”
state_codes=”PA,NJ,TX”]
dotCMS offers the ability to geolocate content OTB (disclaimer, I work for them). You can see a demonstration that displays news content based on the user's location onthe demo site:
It is pretty easy to setup and use. Any type of content can be geolocated and the content can be accessed through the RESTful API. Under the covers, the Geolocation queries are handled natively via Elasticsearch.
Example:
http://demo.dotcms.com/demos/content-geolocation
Docs:
http://dotcms.com/docs/latest/es-geolocation-queries
We have a site that serves up the same content but on country specific domains - so a potential duplicate content issue.
After doing some research, we went with Google's recommendation of using country specific domains instead of www.domain.com/country-directory/
However, when you search from another country, the correct domain does not appear. We have a person in Australia and every time they search google, the .com.au domain doesn't show up.
We have both country domains setup in Google's Webmaster's tools and both have country specific sitemap.xml files which Webmaster tools has no issue with seeing - in fact, there are no errors of any kind (crawl errors etc) as far as Webmaster tools is concerned.
Does anyone know what we might be doing wrong?
Make sure your australian friend is using http://google.com.au. You can conduct the search yourself on their to check if it is working or not, you do not need someone in another country to do so.
There are a lot of geocode services out there (like http://geo-autocomplete.googlecode.com/svn/trunk/demo/ui.demo.html for example) where user can write a location (or part of it) and it will be resolved to real existing location.
There is also a lot of info provided with the search result (like country ISO code, coordinates, etc..), but none of the services seem to provide country and city code.
What I mean is a code used to phone to certain are. For example Country code for Germany will be 49 and for city of Dusseldorf will be 211.
Is there any service, where I can get this info from the user input. Or is there any way to combine the two. For example I get city name from google geocode service and the try it on some city codes database. If yes, can anyone please provide me with links.
You can use for instance Yahoo's GeoPlanet. For more elaboration on services to solve your problem you might want to check out this answer on gis.stackexchange.com, which seems to cover the kind of service you need.