|
@@ -65,19 +65,21 @@ def html2img(driver, image_folder):
|
|
|
if j == 0:
|
|
|
driver.execute_script("window.scrollBy(0,0)")
|
|
|
# print(0)
|
|
|
- elif j == n1 and last_height > 0: # 截取尾部
|
|
|
- # driver.execute_script("$('#app #resetcss').css('margin-bottom', '{}px')".format(web_height))
|
|
|
- driver.execute_script("window.scrollBy(0,{})".format(last_height)) # 滚动条滚到底
|
|
|
-
|
|
|
- # 最后一屏先进行一次保存
|
|
|
- sleep(1)
|
|
|
- origin_last_img = r'{}/{}.png'.format(image_folder, j + 1000)
|
|
|
- driver.save_screenshot(origin_last_img)
|
|
|
-
|
|
|
- # 截取上面重叠的一部分并保存截取后的图片
|
|
|
- new_last_img = r'{}/{}.png'.format(image_folder, j)
|
|
|
- crop_height = web_height - last_height
|
|
|
- crop_img_top(origin_last_img, new_last_img, crop_height)
|
|
|
+ elif j == n1:
|
|
|
+ # print(f'n1 is {n1}')
|
|
|
+ if last_height > 0:
|
|
|
+ # driver.execute_script("$('#app #resetcss').css('margin-bottom', '{}px')".format(web_height))
|
|
|
+ driver.execute_script("window.scrollBy(0,{})".format(last_height)) # 滚动条滚到底
|
|
|
+
|
|
|
+ # 最后一屏先进行一次保存
|
|
|
+ sleep(1)
|
|
|
+ origin_last_img = r'{}/{}.png'.format(image_folder, j + 1000)
|
|
|
+ driver.save_screenshot(origin_last_img)
|
|
|
+
|
|
|
+ # 截取上面重叠的一部分并保存截取后的图片
|
|
|
+ new_last_img = r'{}/{}.png'.format(image_folder, j)
|
|
|
+ crop_height = web_height - last_height
|
|
|
+ crop_img_top(origin_last_img, new_last_img, crop_height)
|
|
|
|
|
|
is_end = 1
|
|
|
print("拉到底拉")
|