-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsaveCityScreenshot.py
43 lines (38 loc) · 1 KB
/
saveCityScreenshot.py
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
# -*- coding: utf-8 -*-
#!/usr/bin/python
"""
使用selenium打开浏览器,然后截图,被server调用,支持flash截图
Authors: wangxiaogang02([email protected])
Date: 2015/08/26 17:23:06
"""
from selenium import webdriver
import io
import sys
import time
import re
import os
import _winreg
import datetime
def capture(url, save_fn):
"""使用selenium打开浏览器,然后截图"""
browser = webdriver.Chrome(executable_path=
"C:\Program Files (x86)\Google\Chrome\Application\chromedriver")
try:
# browser.set_window_size(1200, 900)
browser.get(url) # Load page
time.sleep(4)
browser.save_screenshot(save_fn)
# 退出chrome不退出驱动
# browser.close()
# 关闭chrome并退出驱动
except:
print("exception url:" + url)
finally:
browser.quit()
def main():
"""主函数"""
url = sys.argv[1]
save_fn = sys.argv[2]
capture(url, save_fn)
if __name__ == '__main__':
main()