from selenium import webdriver import selenium.webdriver.support.ui as ui import time opt = webdriver.ChromeOptions() # 无界面 opt.set_headless() # 设置分辨率 opt.add_argument("window-size=1900x3000") driver_item = webdriver.Chrome(options=opt) # driver_item = webdriver.Chrome() # webqq利用的是ajax加载 driver_item.get("https://xui.ptlogin2.qq.com/cgi-bin/xlogin?proxy_url=https%3A//qzs.qq.com/qzone/v6/portal/proxy.html&d&hide_title_bar=1&low_login=0&qlogin_auterifyimg=1&link_target=blank&appid=549000912&style=22&target=self&s_url=https%3A%2F%2Fqzs.qq.com%2Fqzone%2Fv5%2Floginsucc_qr_link=https%3A//z.qzone.com/download.html&self_regurl=https%3A//qzs.qq.com/qzone/v6/reg/index.html&pt_qr_help_link=https%3A//z.qzone.com/download.html&pt_no_auth=0") # 让浏览器窗口最大化 driver_item.maximize_window() print(driver_item.page_source) wait = ui.WebDriverWait(driver_item,10) wait.until(lambda driver: driver.find_element_by_id("img_out_1848650532")) driver_item.find_element_by_id("img_out_1848650532").click() time.sleep(2) # 保存截图 driver_item.save_screenshot("webQQ.png") driver_item.close()