Python获取Origin官网视频
程序说明:最近学习origin,看到官网有入门视频(http://www.originlab.com/index.aspx?go=SUPPORT/VideoTutorials),看着挺多的,就用python写了个简单的爬虫程序,把origin的这些视频下载下来了。利用了requests和bs4解析html,利用re.match方法匹配获取相关连接,最后下载。程序代码没有进行进一步整理,看着有些乱。
#!/usr/bin/python
# -*- coding:utf-8 -*- """
Created on Sun Dec 12 14:21:15 2015 Notes: Downloading turtorial vedios from Origin support. @author: zhigang
""" import requests
from bs4 import BeautifulSoup as bs
import re
import urllib
def download_url(url,outdir):
print('Resolving.....from '+url+'....')
import os.path
if not os.path.exists(outdir):os.mkdir(outdir)
response = requests.get(url)
soup = bs(response.text,"lxml")
all_links = []
all_names = [] for x in soup.findAll("a"):
#通配符匹配获得想要的文件名保存到list中
if "href" in x.attrs.keys():
if re.match('.*VideoTutorials&pid.*',x['href']):
information = [x['href'],x.string]
cur_url = 'http://www.originlab.com/'+information[0]
res_new = requests.get(cur_url)
soup_new = bs(res_new.text,"lxml")
for new_alink in soup_new.findAll('a'):
if 'href' in new_alink.attrs.keys():
if re.match('.*mp4',new_alink['href']):
all_links.append(new_alink['href'])
all_names.append(information[1]+'.mp4') #start downloads
print(str(len(all_links))+' tasks found. Started downloading...')
for (i,link) in enumerate(all_links):
print(str(i)+' : '+all_names[i]+'\t url: '+link)
urllib.request.urlretrieve(link,outdir+'\\'+all_names[i])
print(str(i)+' : '+link+'\t completed...')
print('All tasks completed.') if __name__=='__main__':
url = 'http://www.originlab.com/index.aspx?go=SUPPORT/VideoTutorials'
outdir = r'D:\Origin_turtorials'
download_url(url,outdir)
Python获取Origin官网视频的更多相关文章
- Python第三方库官网
Python第三方库官网 https://pypi.python.org/pypi 包下载后的处理: 下载后放到Python的scripts文件夹中(D:\Python3.5\Scripts),用cm ...
- RPA UiPath 官网视频
RPA UiPath 官网视频相关学习 有一些官网的截图翻译,本来打算把考试题也整理出来,结果没整,另附官网视频 RPA的好处: 广泛的自动化:跨越越来越多的行业,RPA加速在银行和金融,保险,医疗 ...
- Python访问Amazon官网异常
使用Python访问亚马逊(Amazon)官网,如果没有将headers更改为浏览器的信息, 有几率会触发:检测到当前可能是自动程序,需要输入验证码: 将header修改成浏览器后,需要等一段时间或者 ...
- ajax的post请求获取kfc官网数据
# _*_ coding : utf-8 _*_# @Time : 2021/11/2 13:45# @Author : 秋泊酱 # 1页 # http://www.kfc.com.cn/kfccda ...
- python爬虫 beutifulsoup4_1官网介绍
http://www.crummy.com/software/BeautifulSoup/bs4/doc/ Beautiful Soup Documentation Beautiful Soup is ...
- python 爬虫 scrapy1_官网教程
Python爬虫视频教程零基础小白到scrapy爬虫高手-轻松入门 https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.482434a6E ...
- python常用包官网
Pandas http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.reset_index.html?high ...
- #使用parser获取图片信息,输出Python官网发布的会议时间、名称和地点。
# !/usr/bin/env/Python3 # - * - coding: utf-8 - * - from html.parser import HTMLParser import urllib ...
- Python自学笔记-生成器(来自廖雪峰的官网Python3)
感觉廖雪峰的官网http://www.liaoxuefeng.com/里面的教程不错,所以学习一下,把需要复习的摘抄一下. 以下内容主要为了自己复习用,详细内容请登录廖雪峰的官网查看. 生成器 通过列 ...
随机推荐
- iOS 通知中心扩展制作初步-b
涉及的 Session 有 Creating Extensions for iOS and OS X, Part 1 Creating Extensions for iOS and OS X, Par ...
- javascript学习代码--点击按钮显示内容
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Nodejs异步
http://cnodejs.org/topic/4f16442ccae1f4aa2700113b http://cnodejs.org/topic/4f16442ccae1f4aa27001123 ...
- codeforces D. Pashmak and Parmida's problem
http://codeforces.com/contest/459/problem/D 题意:给你n个数,然后统计多少组(i,j)使得f(1,i,ai)>f(j,n,aj); 思路:先从左往右统 ...
- Android 每天定时提醒功能实现
android要实现定时的功能那肯定就要用到闹铃相关的技术, 那么android闹铃实现是基于 AlarmManager 这个类的,首先我们来看一下它的几个主要的方法. 打开AlarmManager的 ...
- 14.5.4 Phantom Rows 幻影行
14.5.4 Phantom Rows 幻影行 所谓的幻读问题发生在一个事务 当相同的查询产生不同的结果集在不同的时间. 例如,如果一个SELECT 是执行2次,但是第2次返回的时间不第一次返回不同, ...
- vs2015
1.关闭诊断工具 vs2015在程序启动之后,自带了内存和cpu使用情况查看的诊断工具. 不喜欢这个,直接点击诊断工具右上角的关闭按钮 2.解决方案资源管理器 程序启动之后,解决方案资源管理器,被收缩 ...
- BZOJ1617: [Usaco2008 Mar]River Crossing渡河问题
1617: [Usaco2008 Mar]River Crossing渡河问题 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 654 Solved: 4 ...
- 宝洁HR
宝洁HR系统的测试犯了很多错误 1 最基本也是最弱智的错误:测试根本不仔细,多轮测试后仍然会发现前几轮应该发现的bug. 纠结测试不仔细的原因 a 个人工作坏习惯 老是认为理所当然,对于一些内容,总 ...
- LOL游戏程序中对一些函数的Hook记录(Win10 x64)
[PC Hunter Standard][League of Legends.exe-->Ring3 Hook]: 108Hooked Object Hook Address and Locat ...