day_04

豌豆荚游戏信息搜取

from selenium import  webdriver
from selenium.webdriver.common.keys import Keys
driver=webdriver.Chrome(r'C:\Users\Administrator\Desktop\chromedriver.exe')
import time
try:
    driver.implicitly_wait(10)
    driver.get('https://www.wandoujia.com/category/6001')
    app_list=driver.find_elements_by_class_name('card')
    for app in app_list:
        app_name=app.find_element_by_css_selector('.app-title-h2 a').text
        detail_url=app.find_element_by_css_selector('.app-title-h2 a').get_attribute('href')
        download_num=app.find_element_by_css_selector('.meta span.install-count').text
        app_size=app.find_element_by_class_name('meta').text
        app_content=f'''
        =======================
        名称:{app_name}    
        详情页url:{detail_url}
        下载人数:{download_num}
        app大小:{app_size}
        ========================
        \n
        '''
        print(app_content)
        with open('app.txt','a',encoding='utf-8') as f:
            f.write(app_content)
finally:
    driver.close()

 

posted @ 2019-07-04 09:18  非道版  阅读(106)  评论(0编辑  收藏  举报