import time import requests from selenium import webdriver from selenium.webdriver.common.keys import Keys ''' 游戏名称 游戏大小 下载人数 游戏简介 下载地址 ''' def get_app(driver): app_list = driver.find_elements_by_class_name('card') for app in app_list: app_name = app.find_element_by_class_name('app-title-h2').text app_count = app.find_element_by_class_name('install-count').text app_size = app.find_element_by_css_selector('.meta span').get_attribute('title') app_com = app.find_element_by_class_name('comment').text app_url = app.find_element_by_css_selector('.icon-wrap a').get_attribute('href') app_content = f''' 游戏名称:{app_name} 游戏大小:{app_size} 下载人数:{app_count} 游戏简介:{app_com} 下载地址:{app_url} ''' print(app_content) with open('wdj.text','a',encoding='utf-8')as f: f.write(app_content) print('导入成功...') if __name__ == '__main__': try: driver = webdriver.Chrome('E:\chromedriver_win32\chromedriver.exe') driver.implicitly_wait(5) driver.get('https://www.wandoujia.com/category/6001') get_app(driver) finally: driver.close()