Countries: A list of their state/province and cities list - django

I want to get all the countries, their states/province and cities in the world.
Where can I find this information?
Somebody please help me. I have searched many times, but I couldn't find it anywhere.

Check out django-cities which provides a list of countries and cities of the world. You will need to use http://www.geonames.org/ to import their database. Alternatively, you can directly download their database (in text format) and extract the values you need.

You can try using Yahoo's GeoPlanet API.
http://developer.yahoo.com/geo/geoplanet/guide/api-reference.html#api-countries
The more specifically relevant portions are on
/countries/
/counties/{state}
There are even examples on how to retrieve entire list of countries on the page. Based on the state, you can also retrieve counties.
Additional:
If you are more specifically looking to do geocoding, you can try Google Maps Geocoding API located below:
https://developers.google.com/maps/documentation/geocoding/?hl=fr
This will allow you to get region specific information on your location of interest.

Related

How should I create a simple enough regex for multiple specified URLs with two different parent paths for Google Analytics?

First ever question post - so apologies in advance.
I have created the Custom Report in Google Analytics
and I'm trying to create a list of matching slugs to two different parent folders to sit within the same custom report.
I can get this to work as a custom report:
/courses/(course-slug-1|course-slug-2)$
the problem is I can't add this set of regex to it as well without breaking the custom report;
/study/faculty/(key-page-1|key-page-2)$
How is the way i should bundle this regex to show these pages. For context there is 63 course page urls and 5 key pages I want in this same custom report to bring it to a total of 68.
Thanks very much
Filters in custom reports get applied in series. The first filter limits the data, then second filter is applied to that already-filtered set, and so on.
You need to create the regex expression in a single filter:
/courses/(course-slug-1|course-slug-2)$|/study/faculty/(key-page-1|key-page-2)$
That should do it.

How do I get the pageid from a Wikipedia page?

In a Flask app, or even better just using wikipedia APIs, how can I get the pageid from a Wikipedia url?
I mean from this http://en.wikipedia.org/wiki/Stack_Overflow to this http://en.wikipedia.org/wiki?curid=21721040
From the API sandbox I can work it out but only as a search from a title, not from a singular URL.
Said search example:
https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&prop=pageprops&format=json&ppprop=wikibase_item&titles=Stack%20Overflow
Can I query for it in a more straightforward way and without resorting to a wikipedia search? I mean I already know the human readable url...
No, you cannot use URLs in the API, you need to use either page names or page ids to identify articles.
Notice that the https://en.wikipedia.org/w/api.php?action=query&titles=Stack%20Overflow you found is not a "search", it's just exactly the query to get you the page id from the title. Use it.

How to I combine Page-views for a URL when they have different query strings in Google Analytics?

I am trying to do some reporting on page views on a site and the results are being listed like the following:
www.example.com/directory/ - 100 views
www.example.com/directory/?id=123456 - 10 views
www.example.com/directory/?id=987654 - 5 views
What filter do I need to create to views the results as:
www.example.com/directory/ - 100 views
www.example.com/directory/?id=* - 15 views
Thanks in advance
Yes, getting historical grouped together is going to mean using something like Google Docs, Excel, Tableau Software, Analytics Canvas, etc.
Moving forward...
One of the simplest ways of keeping things grouped in GA is to set up an advanced profile filter. You'll want to use this with a new profile; keeping a "raw" or "empty" profile is highly advisable for when you actually want to look at those individual URLs.
That said, here's a filter pattern that should work for you:
Go to Admin > Filters (under the View Column)
+ New Filter > Create new Filter > Name it
Filter Type = Custom filter > Advanced
Here's the pattern:
Field A: www\.example\.com\/directory\/\?id=.+
Output To: www\.example\.com\/directory\/\?id=\*
Another way to aggregate the same URI with multiple query strings is to change the primary dimension to 'Page Title' under Behavior > Site Content > All Pages.
The best way to do this for your historical data is unfortunately in an excel pivot table. You can get in in the UI, but only by creating a custom report and searching for very specific directories.
Check out the documentation on excluding query strings in your GA profile. Maybe create a new profile and write an advanced rule to rewrite all "id" pages to "/directory/product-page".
A totally different approach is to use custom variables or custom dimensions and to stop looking in the normal "Behavior" reports section (used to be called "Content" in GA) – custom dims are available using Google Analytics Universal Analytics only, which means starting a new web property and possibly running both code snippets concurrently (totally safe to do).
Personally I find custom dimensions a bit easier to work with than custom variables, and I generally think that it's a good idea to start exploring the new Google Analytics.
The nice thing about either of these approaches is that you can still keep the full page path date in the same profile as your custom dimension / variables information; it'll stay in the Behavior section where it belongs with all the other page paths.
Where I'm going with this...
You can create a new dimension such as "page type" and then call it "products", "posts", "articles", or whatever these id #s represent in this /directory/; then you can look at metrics across the dimension like pageviews, time on page, etc. by page type.
You can even create other dimensions to help describe them in more detail, such as breaking down blog posts or products into their different categories; i.e. hierarchical dimensions. Once you start using this kind of thing you may wonder what you ever did without it!
I think it's fair that I stop this answer now since it's not about how to set up custom variables or custom dimensions; those links should get you started (it's really not difficult).
Note: You can use php to fill in the dimension information in the GA tracking snippet dynamically based on the page that is being viewed (again, that's another question).

How to get specific episode from iTunes API?

How do I get a link to a specific episode of a TV show in the iTunes store? I have the name of the show*, the season, and episode number. From the documentation, I've found that I can get a list of episodes, and then parse the JSON to find the episode and its iTunes links.
However, the documentation also says that one should avoid making too many or too big requests (e.g. by using the limit parameter), so I'm wondering if there is a better way to directly get the desired episode link, without fetching and parsing a potentially huge list of episodes.
*) In case the season name is ambiguous, I have the TVDB data, and can also specify a 'canonical' name if neccessary.
The Search API has a few parameters that will help qualify the content you want returned.
It sounds like you should be using the Show title as the "term".
https://itunes.apple.com/search?term=Jersey+Shore&attribute=tvSeasonTerm&entity=tvEpisode
Adding "attribute=tvSeason" will ensure the term is matched only to TV Show titles and not any other meta data in the iTunes store (including music, movies, apps etc.).
Also, appending "entity=tvEpisode" will indicate to the API that you want only Episodes returned and not just the Season info (by default).

Where I can find restaurant data for android application?

I would like to know if there is a free api that would allow me to get restaurant information for an android application. The Application is supposed to search for nearby restaurants and display to the user. The problem is that there are some criteria that the restaurants must satisfy. The specific information I need is: location, type of food (mexican, italian, burger, etc.), type of restaurant (sit-down, fast food, buffet, etc.). Would there be any api that would give me these information? I know that I can use apis like Google custom search but the problem is that the result may not include all the information I want to have on every query( type of food, type of restaurant...)
thanks
As mentioned, the Yelp! API allows you to filter based on a lot of categories. The other alternative would be the Google Places API, but that doesn't give you the sort of contextual information about the restaurant that you want.