예제 #1
0
    link = child.a['href']
    title = child.img['title']
    paltform = "youku"
    type = "gametop10"
    content = title
    cover_pic = child.img['src']
    rank = i
    ol = child.find_all("dd", {"class": "detail"})[0].find("a").contents[0]
    memo1 = ''
    ctime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
    database.query_dic({
        'insert':
        'popular_zy_top5',
        'domain_array': [
            'title', 'link', 'paltform', 'type', 'content', 'cover_pic',
            'rank', 'ol', 'memo1', 'ctime'
        ],
        'value_array': [
            title, link, paltform, type, content, cover_pic, rank, ol, memo1,
            ctime
        ]
    })
    # print(link)
    # print(title)
    # print(paltform)
    # print(content)

    # i = i + 1
    # if i >= 11:
    #     break

myDriver.close()
예제 #2
0
div = soup.find_all("div", {"class": "common_w-card"},limit = 20)
for child in div:
     #link = child.a['href']
     title = child.find("p", {"class": "common_w-card_title"}).contents[0]
     paltform = "全民TV"
     type = "热度"
     content = child.find("a", {"class": "common_w-card_category"}).contents[0]
     cover_pic = child.img['src']
     rank = i
     ol = child.find("span", {"class": "common_w-card_views-num"}).contents[0]
     
     ctime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
     nickname = child.find("span", {"class": "common_w-card_host-name"}).contents[0]
     roomnum = child.find(
         "a", {"class": "common_w-card_href"})['href'][17:]
     roomname = title
     chour = time.strftime('%Y-%m-%d %H', time.localtime(time.time()))
     database.query_dic({
         'insert': 'popular_feelings_data',
         'domain_array': [
             'title', 'paltform', 'type', 'content', 'cover_pic', 'rank', 'ol',  'ctime',  'nickname',  'room_number',  'room_name',  'chour'
         ],
         'value_array': [
             title, paltform, type, content, cover_pic, rank, ol,  ctime, nickname, roomnum, roomname,chour
         ]
     })
     
myDriver.close()
myDriver.quit()
#display.stop()