-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml-png_code.py
More file actions
31 lines (27 loc) · 1 KB
/
html-png_code.py
File metadata and controls
31 lines (27 loc) · 1 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
# this is the coding for generating html screenshot
# written by Doodle2Code team for MIT 6.962 Applied Machine Learning
import time
from selenium import webdriver
import os
c = 0
n = 0
j = 0
i = 0
for c in range(3):
for n in range(10):
for j in range(10):
for i in range(10):
# name of the file in format of 0000.html
fn = str(c)+str(n)+str(j)+str(i)+".html"
path = '/Users/Username/Desktop/filename/'
tmpurl = 'file://{path}/{mapfile}'.format(
path=path, mapfile=fn) # find the address of the html
driver = webdriver.Chrome()
driver.maximize_window()
# maximum waiting time for opening the html
driver.implicitly_wait(6)
driver.get(tmpurl) # open html
time.sleep(1)
# print("done')
driver.get_screenshot_as_file(
str(c)+str(n)+src(j)+str(i)+".png") # rename the file