Skip to content

Instantly share code, notes, and snippets.

@fprieur
Created January 12, 2015 21:29
Show Gist options
  • Save fprieur/51c2e61a05f5a6b89045 to your computer and use it in GitHub Desktop.
Save fprieur/51c2e61a05f5a6b89045 to your computer and use it in GitHub Desktop.
Scan montreal open data resource
# coding: utf-8
from bs4 import BeautifulSoup
import requests
import json
r = requests.get("http://donnees.ville.montreal.qc.ca/api/3/action/package_list")
binary = r.content
output = json.loads(binary)
for package in output["result"]:
r = requests.get("http://donnees.ville.montreal.qc.ca/dataset/"+package)
data = r.text
soup = BeautifulSoup(data)
for resource_link in soup.findAll("a", {"class": "resource-url-analytics"}):
print(resource_link.get('href'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment