Last active
October 13, 2023 04:03
-
-
Save kevin-chau/0d106f863f59bdc50d764a8ad6edfec8 to your computer and use it in GitHub Desktop.
US Forest Service Research Image Library Scraper
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 requests | |
output_dir = "/Volumes/KCHAU'S T5/US Forest Service Research Image Library/" | |
url_base = 'https://www.fs.usda.gov/rds/imagedb/images/' | |
# 19677 = total number of images in data base | |
file_number = 19677 | |
while file_number > 0: | |
filename = str(file_number) + '.jpg' | |
r = requests.get(url_base + filename) | |
if r.status_code != 404: | |
img_data = r.content | |
with open(output_dir+filename, 'wb') as handler: | |
handler.write(img_data) | |
file_number -= 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment