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/里面的教程不错,所以学习一下,把需要复习的摘抄一下. 以下内容主要为了自己复习用,详细内容请登录廖雪峰的官网查看. 生成器 通过列 ...
随机推荐
- 关于Java(常用数据类型)
工作中,除非特殊需要,一般使用的数据类型较为单一. int int 是最常用的类型之一,一般能满足判断或循环的需求 float 或 double 两个浮点类型,可以在一定程度上确保数据的精度 BigD ...
- MacOS快捷键
- Android 模拟HTTP协议的编码问题 Android默认编码UTF-8
Android通过GET和POST方法请求服务器和浏览器请求的过程是不一样的. 浏览器请求服务器的时候会先将中文进行UTF-8编码,然后再发送到服务器端. Android编程下我们需要通过URLEnc ...
- 【UVA1416】(LA4080) Warfare And Logistics (单源最短路)
题目: Sample Input4 6 10001 3 21 4 42 1 32 3 33 4 14 2 2Sample Output28 38 题意: 给出n个节点m条无向边的图,每条边权都为正.令 ...
- Delphi_OD_代码_调试_Delphi反调试技术(以OD为例附核心原代码)
1.程序窗口[chuang kou]句柄[ju bing]检测原理:用FindWindow函数[han shu]查找[cha zhao]具有相同窗口[chuang kou]类名和标题的窗口[chuan ...
- VC和VS调用Lua设置以及Lua C API使用。
通过c++调用lua 脚本, 环境VC++6.0 lua sdk 5.1.4 在调用前先认识几个函数.1.调用lua_open()将创建一个指向Lua解释器的指针.2. luaL_ope ...
- oracle索引再论
ORACLE中索引的数据结构有B树结构和位图结构. 我们通常用的普通索引.反向键索引.函数索引等都是B树结构的,是树状结构:位图结构则只有叶子节点. B树索引操作有唯一性扫描,范围扫描,快速索引全扫描 ...
- 【HDOJ】2888 Check Corners
二维RMQ. /* 2888 */ #include <iostream> #include <algorithm> #include <cstdio> #incl ...
- java学习面向对象之异常之一
一.异常的概述: 什么是异常?在我们编写java程序的时候,会出现一些问题,比如内存溢出啊或者数组索引超出最大索引啊,这些编程当中出现的这些个问题就是异常.但是异常也分为可以处理的和不可以处理的.比如 ...
- BZOJ1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛
1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 665 Solved: 419 ...