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/里面的教程不错,所以学习一下,把需要复习的摘抄一下. 以下内容主要为了自己复习用,详细内容请登录廖雪峰的官网查看. 生成器 通过列 ...
随机推荐
- 面试cookie
cookie : 存储数据,当用户访问了某个网站(网页)的时候,我们就可以通过cookie来像访问者电脑上存储数据 1.不同的浏览器存放的cookie位置不一样,也是不能通用的 2.cookie的存储 ...
- 使用ListItem给DropDownList填充数据
global::日积月累啥的啊.DBhelper db = new 日积月累啥的啊.DBhelper(); ListItem[] item=]; DataTable dt=db.GetDataTabl ...
- Book of Evil
Codeforces Round #196 (Div. 2) D:http://codeforces.com/contest/337/status/D 题意:给你一个树,然后树中有一m个点,求到这m个 ...
- [LeetCode#260]Single Number III
Problem: Given an array of numbers nums, in which exactly two elements appear only once and all the ...
- Apache CloudStack多个跨站脚本漏洞(CVE-2013-2136)
漏洞版本: Apache Group CloudStack 4.1.0 Apache Group CloudStack 4.0.2 Apache Group CloudStack 4.0.1-incu ...
- 【转】VMware 11安装Mac OS X 10.10 及安装Mac Vmware Tools.
原文网址:http://www.cnblogs.com/Anand/p/4483727.html 先上一张效果图兴奋一下,博主穷屌丝一个,只能通过虚拟黑苹果体验下高富帅的生活,感觉超爽的,废话不多说的 ...
- jQuery.extend方法和开发中变量的复用
最近在用commonJS规范进行客户端开发,遇到如下问题: 一般一个模块内部可能会定义一系列变量或一系列相关变量,比如写了一个颜色选择弹框模块大概会有如下变量定义 var settings = { / ...
- web.xml中的contextConfigLocation的作用
在web.xml中通过contextConfigLocation配置spring,contextConfigLocation 参数定义了要装入的 Spring 配置文件. 如果想装入多个配置文件,可以 ...
- Learn Objectvie-C on the Mac 2nd Edition 笔记
Chapter 1Apple’s Cocoa (for OS X) 和 Cocoa Touch (for iOS) toolkits 都是用 Objective-C写的. Chapter 2 (1) ...
- Bzoj 3809: Gty的二逼妹子序列 莫队,分块
3809: Gty的二逼妹子序列 Time Limit: 35 Sec Memory Limit: 28 MBSubmit: 868 Solved: 234[Submit][Status][Dis ...