Skip to main content

Intel URL Parsing

This module started as a simple parser for Intel URLs for Niantic Lab’s Ingress game. It then grew, like an ugly monster, to support most flavors of Google Maps and Apple Maps URLs.

When a URL is parsed, we return a structure that contains the latitude and longitude of the place, along with a host of other values, such as a name for the map, potential zoom levels for the map, and human captions if we can decipher them from the map service provider.

See the source code for the exact return values.

Niantic Labs is not responsible for this program, and neither endorses nor supports it. The author is not associated with Niantic Labs and makes no representations.

Use

>>> from intelurls import check_mapurl, parse_mapurl, parse_natural
>>> from pprint import pprint

An Ingress Intel URL:

>>> check_mapurl("this is a string with a url in it https://intel.ingress.com/intel?ll=37.821523,-122.377385&z=17 and more test")
'https://intel.ingress.com/intel?ll=37.821523,-122.377385&z=17'

A Google Maps URL with a caption:

>>> pprint(parse_mapurl("https://maps.google.com/maps?ll=37.765727,-122.431961&cid=10889150637731333995&q=Beck's%20Motor%20Lodge"))
{'caption': "Beck's Motor Lodge",
 'latlng': [37.765727, -122.431961],
 'name': 'map_@37.765727,-122.431961'}

A Google Maps ShortURL:

>>> pprint(parse_mapurl("http://goo.gl/maps/r6T6a"))
{'caption': '',
 'latlng': [45.0215057, 14.6293757],
 'name': 'map_@45.0215057,14.6293757'}

A natural language location:

>>> pprint(parse_natural("San Francisco, CA"))
{'caption': 'San Francisco, CA, USA',
 'latlng': [37.7749295, -122.4194155],
 'name': 'map_@37.7749295,-122.4194155_z13',
 'zoom': 13}

For a full list of everything we can parse, look at tests/gentest.py, this list is fairly extensive.

Testing

There are so many combinations of URLs, that a regression test jig was created. Most of the code is self-contained, however the natural language location and URLs that need expansion or page scraping need to interact with a third party service (typically the Google Maps API) and that data has been known to change over time.

A failed test isn’t a reason to not install the module.

valid.out is correct at the time of this publication, but may get out of date if the third party services change or move map items. If unit test fails, it’s best to examine -why- it failed to see if it is an actual bug or just a change by a third party. If you need to, you may re-create valid.out with gentest.py

ChangeLog

0.0.2: README.rst formatting 0.0.1: Original publication

Release files for intelurls 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for intelurls 0.0.5
File Size Uploaded
intelurls-0.0.5.tar.gz 17.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for intelurls 0.0.5
File Interpreter ABI Platform
intelurls-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 34.4 kB

Release files / intelurls-0.0.5.tar.gz

Download URL intelurls-0.0.5.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ea6395eab00a8080a7a4779c7cbe6df5757a1d127578be5b583bbd64c5337879
BLAKE2b-256 checksum
How to use checksums
a96c698fbdfdab69e223f4e861a80298c3851e0fb9378d51d08d7f8299f53475
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

Release files / intelurls-0.0.5-py3-none-any.whl

Download URL intelurls-0.0.5-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f043b1bd32d8428be8202a500a51adb32a36f98370fb0c9f228dfbf9bd1ce87
BLAKE2b-256 checksum
How to use checksums
261f7abe62b43717df3ddb485ff594dbe6a1bb5d23f572bb2523f1333124d184
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page