最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python使用beautifulsoup從愛奇藝網(wǎng)抓取視頻播放

 更新時(shí)間:2014年01月23日 09:21:59   作者:  
這篇文章主要介紹了python使用beautifulsoup從愛奇藝網(wǎng)抓取視頻并播放示例,大家參考使用吧

復(fù)制代碼 代碼如下:

import sys
import urllib
from urllib import request
import os
from bs4 import BeautifulSoup

class DramaItem:
    def __init__(self, num, title, url):
        self.num = num
        self.title = title
        self.url = url
    def __str__(self):
        return self.num + '    ' + self.title
    def openDrama(self):
        os.startfile(self.url)

response = urllib.request.urlopen('http://www.iqiyi.com/a_19rrgja8xd.html')
html = response.read()
soup = BeautifulSoup(html)
dramaList = soup.findAll('div', attrs={'class':'list_block1 align_c'})
dramaItems = []

if(dramaList):
    lis = dramaList[0].findAll('li')
    for li in lis:
        ps = li.findAll('p')
        description = ps[1].text if len(ps)>1 else ''
        num = ps[0].find('a').text
        url = ps[0].find('a')['href']
        di = DramaItem(num, description, url)
        dramaItems.append(di)

for di in dramaItems:
    print(di)
diLen = len(dramaItems)
userChoice = int(input('input number to watch the drama:'))
if userChoice >= 1 and userChoice <=diLen:
    dramaItems[userChoice-1].openDrama()



相關(guān)文章

最新評(píng)論

镇巴县| 綦江县| 扬中市| 凤山市| 高淳县| 札达县| 凯里市| 光山县| 淳安县| 青海省| 长垣县| 海兴县| 晴隆县| 南开区| 宁南县| 嵊泗县| 信阳市| 鄂尔多斯市| 宝应县| 开远市| 抚顺县| 青冈县| 桓台县| 吉木萨尔县| 基隆市| 安远县| 池州市| 公主岭市| 凤山县| 饶河县| 西华县| 石首市| 巧家县| 梅州市| 龙山县| 五莲县| 孝感市| 营山县| 当涂县| 定襄县| 宝兴县|