from selenium import webdriver from selenium.webdriver.chrome.options import Options import time import os from bs4 import BeautifulSoup # os.environ["PATH"] += os.pathsep + 'D:\google-art-downloader-master'
try: img1 = browser.find_element_by_xpath('//*[@id="baidu_image_holder"]/a/img') if img1 != None: images_all.add(img1.get_attribute('src')) except Exception as e: pass
try: img2 = browser.find_element_by_xpath('//*[@id="baidu_image_holder"]/img') if img2 != None: images_all.add(img2.get_attribute('src')) except Exception as e: pass time.sleep(1) withopen("huaban_images_all.txt",'w',encoding="utf8") as write_file: for line in images_all: write_file.write(str(line) + "\n") except Exception as e: browser.close()