-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathweb_capture.py
More file actions
44 lines (35 loc) · 1.19 KB
/
web_capture.py
File metadata and controls
44 lines (35 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/bash
# Takes screenshot of a web page using selenium
# Usage 1:
# File containing line separated URLs:
# python web_capture.py url_file.txt
# Usage 2:
# List of URLs hardcoded in "urls = []"
# Example: urls = ["http://127.0.0.1","https://127.0.0.1"]
# one line code
# python -c "from selenium import webdriver; driver = webdriver.Firefox(); driver.get('http://127.0.0.1'); driver.save_screenshot('capture.png'); driver.quit()"
try:
import sys
from selenium import webdriver
except:
print "[!] You should have selenium installed. Run: pip install selenium"
sys.exit(1)
urls = []
if len(sys.argv)>=2:
f = open(sys.argv[1], "r")
data = f.readlines()
del urls[:]
for test_url in data:
test_url = (test_url.replace("\r","")).replace("\n","")
urls.append(test_url)
#https://github.com/ariya/phantomjs
#driver = webdriver.PhantomJS("/path/to/phantomjs/binary/file")
#https://sites.google.com/a/chromium.org/chromedriver/downloads
#driver = webdriver.Chrome("/path/to/chromedriver/binary/file")
driver = webdriver.Firefox()
count = 0;
for myurl in urls:
driver.get(myurl)
driver.save_screenshot(str(count)+'.png')
count = count + 1
driver.quit()