from selenium import webdriver import time driver = webdriver.Chrome() try: driver.implicitly_wait(20) driver.get('https://www.wandoujia.com/category/6001') time.sleep(5) js_code = ''' window.scrollTo(0,5000) ''' driver.execute_script(js_code) time.sleep(5) # 商品信息加载,等待5s app_list = driver.find_elements_by_class_name('card') for App in app_list: # App name app_name = app.find_element_by_css_selector ( ' the .app-title-h2 A ' ) .text # details page url detail_url = app.find_element_by_css_selector ( ' the .app-title-h2 A ' ) .get_attribute ( ' href ' ) # number of downloads # App size download_num_size = app.find_element_by_class_name ( ' Meta ' ) .text app_content = "" " =================== App name: {} details page url: {} Download number: {} app size: {} =================== \ the n- "" " .format (app_name, detail_url, download_num_size [: 8 ], download_num_size [. 11 :]) Print (app_content) with Open ( ' pea pods app.txt ' , ' A ' , encoding = ' UTF-. 8 ' ) AS F: f.write (app_content) the time.sleep ( . 3 ) a finally : driver.close ()