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/里面的教程不错,所以学习一下,把需要复习的摘抄一下. 以下内容主要为了自己复习用,详细内容请登录廖雪峰的官网查看. 生成器 通过列 ...
随机推荐
- go 语言与循环
package main import "fmt" type Employee struct{name string; age int} func displayName(e *E ...
- LightOj_1342 Aladdin and the Magical Sticks
题目链接 题意: 地上有n种棍子, 其中有两种类型, 一种类型是可识别, 一种类型是不可识别, 每个棍子都有一个权值. 当你捡到可识别的, 那么你以后就不会再捡这个棍子, 如果是不可识别的, 那么你有 ...
- Spring4.0整合Hibernate3 .6
转载自:http://greatwqs.iteye.com/blog/1044271 6.5 Spring整合Hibernate 时至今日,可能极少有J2EE应用会直接以JDBC方式进行持久层访问. ...
- codeforces C. Jzzhu and Chocolate
http://codeforces.com/contest/450/problem/C 题意:一个n×m的矩形,然后可以通过横着切竖着切,求切完k次之后最小矩形面积的最大值. 思路:设k1为横着切的次 ...
- 【HDOJ】1686 Oulipo
kmp算法. #include <cstdio> #include <cstring> ], des[]; ], total; void kmp(char des[], cha ...
- luoguP2265 路边的水沟
题目:http://www.luogu.org/problem/show?pid=2265 题解:ans=C(n+m,n)%p 求一下逆元就行 代码: #include<cstdio> # ...
- Tap.js
Tap.js A lightweight ‘tap’ event JavaScript plugin
- 【转】Android编译系统详解(三)——编译流程详解
原文网址:http://www.cloudchou.com/android/post-276.html 本文原创作者:Cloud Chou. 欢迎转载,请注明出处和本文链接 1.概述 编译Androi ...
- 利用MVC的过滤器实现url的参数加密和解密
最近在与一个IOS应用做接口对接,之前一直都没有遇到什么很大的问题,但是有一天发现可以通过软件解析app的url,然后直接通过url的拼接修改接口数据,这一下使得数据的安全性和准确性都降低了,于是就想 ...
- 转-----实现基本的Ajax和Json请求
前面已经封装好了一个方法ajax(),通过这个方法可以实现Ajax请求,接下来就是给出 例程来测试这个方法和实现简单的功能. 视图的部分代码如下: 1 2 3 4 5 6 7 8 9 <bo ...