Skip to content

Commit

Permalink
finished
Browse files Browse the repository at this point in the history
  • Loading branch information
Edit-Mr committed Nov 6, 2023
1 parent 14b27f4 commit 96d7a0c
Show file tree
Hide file tree
Showing 3 changed files with 1,084 additions and 85 deletions.
15 changes: 15 additions & 0 deletions code/下載多張圖片.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import requests
image_links = [
"https://picsum.photos/200/300","https://picsum.photos/200/300",
"https://picsum.photos/200/300","https://picsum.photos/200/300",
"https://picsum.photos/200/300",
]
for index, link in enumerate(image_links):
try:
response = requests.get(link)
response.raise_for_status()
with open(f"image_{index+1}.jpg", "wb") as file:
file.write(response.content)
print(f"圖片{index+1}下載成功")
except requests.exceptions.RequestException as e:
print(f"圖片{index+1}下載失敗: {e}")
Loading

0 comments on commit 96d7a0c

Please sign in to comment.