Script to upload city websites

Hi,
For another project, I’m gathering municipal websites for countries of Europe. While the list won’t be complete (or 100% error proof), I think it would be an added value to OSM.

You can find the page here:
https://wiki.openstreetmap.org/wiki/Automated_edits/JurgenG/European_municipality_websites

Just doing this in my free time in an effort to give back to the community.
Any objections of feedback?

1 Like

Hello to you too and nice mini-project, with a quick glance.
One thing to consider is that it corresponds to the proper admin_level, because some countries may not have the same concept of municipalities for administrative entity (meaning they may have different entity for that) and not to be confused with subdivisions which don’t have administrative role.

Yes, I noticed that. There’s a great page about that, that I found when I started looking around:
https://wiki.openstreetmap.org/wiki/Tag:boundary%3Dadministrative#admin_level=*_Country_specific_values

For the Netherlands, please post the OSM XML you would upload for review on the Dutch forum prior to uploading. It will get the attention it needs there.

In the Netherlands you will want the admin_level=8 relations.

By the way, Dantumadiel uses a .frl domain. I’ll add that manually, but that is one exception you may encounter among the .nl domains. This will only occur in the province Frisia.

Sorry for the amateurish questions, presumably you could answer it yourself if you understood the code :wink:

The title says “Europe” but the folder only contains the four countries Belgium, France, Luxembourg and the Netherlands. Will the others be added or is this only about the four?

What do you do if a website is not listed in either OSM or Wikipedia? Do you then simply skip and ignore the municipality? Or do you then create a list to map by hand / MapRoulette.org?

In your approach, you write “start search for other possible sites”. What does this search look like?

Does a country upload all changes in a single changeset?
It seems that it is a good idea to check the changes again afterwards, and an excessively large bbox would make this more difficult. See also:Changeset - OpenStreetMap Wiki

@mcliquid I didn’t miss the sarcasm in your question. Please elaborate on what part of the code isn’t clear to you and I’ll explain in detail what it means. And yes, I used some AI to help me write the code. Just like I used autocomplete a decade ago and color coding 30 years ago (but admittedly, back then it was in PHP).

Actually, I’m trying to narrow it down to municipality lists as ordained by the countries (see the few examples given in the wiki page). So these are essentially being created by hand based on official sources.
I don’t need the sites to be in OSM. I just need them for a different project, and thought: well… maybe I could upload them to OSM while I’ve already done the work.

I would just add the ones I find and don’t submit anything else. For one because not all municipalities have a website. I also don’t intend to be complete. If I add a site by hand, nobody expects that all cities are being tackled. Consider this me being too lazy to manually enter the ones I found.

Basically (after checking OSM and wiki):

  1. Check if there are designated potential sub-tld’s (e.g. gov.uk) that might be applicable and to a HTTP request to cityname.sub.tld (these can only be granted by government and are considered trusted)
  2. Check if cityname.tld returns a HTTP200 (if so, it needs to be validated - but quickly loading the page can be enough if you speak the language)
  3. As a last resort, also check if there’s a cityname.org or cityname.net that exists (yes, they exist in rare occasions)

There’s some more details (e.g. dead links in OSM, or 30x redirects) But the above is also explained in the wiki.

Nope, the idea is to do a single call per city. The requests go pretty slow since they run quite a few tests before going to the next one. But anyways, I also include a small sleep() just to avoid the off-change that a few calls follow each other too quickly.

1 Like

Thanks @JeroenHoek - I’ll try to get in touch with the Dutch forum to get feedback. For the Netherlands, what I would basically do is:

  1. check cityname.nl
  2. (for split names both cityname.nl and city-name.nl)
  3. Given Dutch is my native language (and I went to a Dutch school from age 6 until 10), I’ll do a quick check of the domains to see if they actually are municipality sites.

For NL, I found this page at the CBS where I’ll extract the city names:

If a site already exists, obviously this precedes new sites (unless I land a 50x response)

Good tip for the Frysian tld. France has something similar, I discovered by accident.

Oops, I really didn’t mean that sarcastically! Maybe it is the language barrier. I’m really incredibly bad with programming languages.

All right, so (unfortunately) not Germany, Austria, etc. either, correct?


Thank you very much for your explanations, I was really very interested in them!

What else occurred to me: the French users are not in this forum but in their own: https://forum.openstreetmap.fr/

Actually I intend to do every country, including Germany, Austria, Greece, all the way to Albania, Ukrain, etc…

My apologies, I guess my frustration was getting the overhand a bit. I was thinking if quickly uploading the things I found and all of the sudden I’ve already been working longer on the Wikidocs and community management than that it took me to write the code.

1 Like

There’s also a possibility that the domain may still exist but not being used for the municipality. Or also the possibility that it may be an older version of the municipality’s website that just doesn’t automatically redirect to the new one. Would you consider those scenarios?

Unfortunately, that would take me way too far … I have no clue how I would be able to catch that.


I think I will end this project and just try to generate CSV files for the countries I find. I’ll then share these with the community here and local communities can choose to validate and integrate the findings into their local municipality nodes.

I’ll keep the code online as it is, so others can benefit from it.