与此形成鲜明对比的是另一位巨星——葡萄牙队的c罗。上赛季他虽说有42个进球,但经统计,他的效率不到10%。在这个习惯统计学的社会,c罗的42球从深层分析充满了水分。此外,他的球场道德也属于低劣派,假摔贯穿全场,无处不在,江湖人送外号 "跳水运动员 ",桃色风波更是五花八门,而两者后果呢?看看吧:梅西凭借着08—09赛季带领巴萨取得西甲、国王杯、欧洲冠军联赛三冠王,取得433分,获得金球奖,而c罗只有他的一半不到!
本文实例为大家分享了python自动网页截图并裁剪图片的具体代码,供大家参考,具体内容如下
代码:
# coding=utf-8 import time from selenium import webdriver from selenium.webdriver.chrome.options import Options from PIL import Image import os all_urls = ['http:/****edit'] def login(): chrome_options = Options() chrome_options.add_argument('--headless') driver = webdriver.Chrome(executable_path='./chromedriver',chrome_options=chrome_options) driver.set_window_size(1200, 741) driver.implicitly_wait(2) print('初始化中...') driver.get("http://x*****e") print('填写登录信息中...') acc = driver.find_element_by_id('login-email') pwd = driver.find_element_by_id('login-pass') btn = driver.find_element_by_tag_name('button') acc.send_keys('***') pwd.send_keys('***') btn.click() print('跳转到验证码页面中...') time.sleep(2) capta = driver.find_element_by_id('code') capta_input = input('请输入两步验证码:') capta.send_keys(capta_input) btn1 = driver.find_element_by_tag_name('button') btn1.click() time.sleep(2) print('跳转到创意编辑页面中...') return driver def get_screen(driver,urls): count = 1 for url in urls: driver.get(url) print('正在抓取--> %s'% url) count +=1 time.sleep(2) uid = url.split('/')[-2] cid = url.split('/')[-5] driver.get_screenshot_as_file("./screen_shot/{}-{}.png".format(uid,cid)) print("创意--> {}-{}.png 已经保存".format(uid,cid)) print('还剩 %s 个'% str(len(urls)-count)) def crop_img(): for img in os.listdir('./screen_shot'): if img.endswith('.png'): print('%s裁剪中。。'% img) im = Image.open('./screen_shot/%s'% img) x = 755 y = 162 w = 383 h = 346 region = im.crop((x, y, x+w, y+h)) region.save("./screenshot_final/%s" % img) if __name__ == '__main__': driver = login() get_screen(driver,all_urls) driver.quit() print('所有抓取结束') crop_img() print('所有裁剪结束')
到此这篇关于python实现自动网页截图并裁剪图片就介绍到这了。当你的才华还撑不起你的野心时,那你就应该静下心来学习。更多相关python实现自动网页截图并裁剪图片内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!