regex - How to extract coordinates(lat, lan) from a URL in Python? -
i'm bit lost on how extract coordinates (lat, long) url in python.
always i'll recive url this:
https://www.testweb.com/cordi?ll=41.403781,2.1896&z=17&pll=41.403781,2.1896
where need extract second set of url (in case: 41.403781,2.1896) say, not first , second set of coords same.
i know, can done regex, i'm not enough on it.
here's how regular expression:
import re m = re.search(r'pll=(\d+\.\d+),(\d+\.\d+)', 'https://www.testweb.com/cordi?ll=41.403781,2.1896&z=17&pll=41.403781,2.1896') print m.groups()
result: ('41.403781', '2.1896')
you might want @ module urlparse
more robust solution.
Comments
Post a Comment