视频爬取

一、爬取视频

import re
import requests
"""
@author RansySun
@create 2019-07-22-12:05
"""

response = requests.get('http://www.mod.gov.cn/v/index.htm')
data = response.text
# <a href="2019-06/27/content_4844619.htm" class="img"><img src="attachement/jpg/site21/20190627/309c237042ea1e7f205317.jpg" border="0" width="100%"><div class="text"><em class="video_50x50"></em><h3>2019年6月国防部例行记者会实况</h3><small>2019-06-27</small></div></a>

res_data = re.findall('<a href="(.*?)" class="img">', data)
for res in res_data:
    res = "http://www.mod.gov.cn/v/"+res
    video_response = requests.get(res)
    print(res)
    video_data = video_response.text

    # http://vv.chinamil.com.cn/asset/category3/2019/06/27/asset_357593.mp4

    video_res = re.findall('//Video (.*?.mp4)', video_data)[0]

    print(video_res)
    mp4_response = requests.get(video_res)
    mp4_data = mp4_response.content
    mp4_name = video_res.split("/")[-1]
    fw = open(mp4_name, 'wb')
    fw.write(mp4_data)
    print("成功")

转载于:https://www.cnblogs.com/randysun/p/11231871.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值