python使用beautifulsoup从爱奇艺网抓取视频播放
2014-01-23 00:00
1111 查看
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()
相关文章推荐
- python使用beautifulsoup从爱奇艺网抓取视频播放
- [置顶] 使用python播放视频文件
- python 自学第二课: 使用BeautifulSoup抓取链接 正则表达式
- 使用Python编写简单网络爬虫抓取视频下载资源
- 【PythonDjango后台实例 第七章】Django使用Video.js视频播放插件
- 使用Python编写简单网络爬虫抓取视频下载资源
- Python3.7 爬虫(二)使用 Urllib2 与 BeautifulSoup4 抓取解析网页
- 【实例】python 使用beautifulSoup 抓取网页正文 以淘宝商品价格为例
- 使用python3抓取新浪股票使用beautifulsoup解析和selenium
- python3.4学习笔记(十七) 网络爬虫使用Beautifulsoup4抓取内容
- 使用Python编写简单网络爬虫抓取视频下载资源
- 使用Python编写简单网络爬虫抓取视频下载资源
- Java - 抓取优酷网视频播放页面(使用jsoup解析html,正则表达式处理字符串)
- Android 使用MediaPlayer 播放 视频
- ios播放视频文件一般使用 MPMoviePlayerViewController 和 MPMoviePlayerController
- Unity如何使用WWW类和协程完成图片、视频下载播放(一)
- Android使用VideoView播放网络视频
- iOS开发-BUG:解决在使用MPMoviePlayerController播放视频后导航栏上移的问题
- python:BeautifulSoup 模块使用指南
- python使用BeautifulSoup分析网页信息的方法