We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9701ab0 commit 1027f09Copy full SHA for 1027f09
Image-Scraper/scrape_images.py
@@ -0,0 +1,21 @@
1
+# Scrape all HTML <img> tags from a provided URL.
2
+
3
+from bs4 import BeautifulSoup
4
+import requests
5
+import sys
6
7
+if len(sys.argv) != 2:
8
+ sys.exit("Usage: python scrape_images.py {url}")
9
10
+response = requests.get(
11
+ sys.argv[1],
12
+ headers={
13
+ "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36"
14
+ }
15
+)
16
17
+html_data = BeautifulSoup(response.text, 'html.parser')
18
+images = html_data.find_all('img', src=True)
19
20
+for image in images:
21
+ print(image)
0 commit comments