Created
October 3, 2019 03:04
-
-
Save jvani/043438d83f2ab542cee087d5aa1b1395 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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