Skip to content

Instantly share code, notes, and snippets.

@Bouni
Created September 6, 2018 15:03
Show Gist options
  • Save Bouni/1abf90dd16fed9e26d3a15b316b4a6ea to your computer and use it in GitHub Desktop.
Save Bouni/1abf90dd16fed9e26d3a15b316b4a6ea to your computer and use it in GitHub Desktop.
swiss_hydrological_data regex
location = re.findall(r"<option selected=\"selected\" value=\"\d+\">(.*)\s\(\s\d+\s\)</option>", response.text)
location = [s.strip() for s in location[0].split("-")]
captions = re.findall(r"<th class=\"text-center\" scope=\"col\">(\w+)<br>", response.text)
data = re.findall(r"<td class=\"text-center\">([\d\.]+)</td>", response.text)
['Rhein', 'Rekingen']
['Abfluss', 'Wasserstand', 'Temperatur']
['261', '322.28', '21.1', '250', '322.25', '21.1', '264', '322.29', '21.2']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment