Skip to content

Instantly share code, notes, and snippets.

@jvani
Created October 3, 2019 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvani/043438d83f2ab542cee087d5aa1b1395 to your computer and use it in GitHub Desktop.
Save jvani/043438d83f2ab542cee087d5aa1b1395 to your computer and use it in GitHub Desktop.
import parsel
import requests
import datetime as dt
if __name__ == "__main__":
url = 'https://webcams.nyctmc.org/multiview2.php'
resp = requests.get(url)
selector = parsel.Selector(resp.text)
n_total = len(selector.xpath('//tr[@id="repCam__ctl0_trCam"]'))
n_inactive = len(selector.xpath('//tr[@id="repCam__ctl0_trCam"]//*[contains(text(), "Inactive")]'))
print(f'Cameras listed as of {dt.datetime.now().isoformat()}')
print(f'See: {url}')
print(f'Total cameras: {n_total}')
print(f'Inactive cameras: {n_inactive}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment