爬虫 python的第一天

1、安装pycharm及python相关的安装

2、新建python项目

3、引包 import requests

pip install requests

4、打开网页,找打你想要爬的数据URL

 

5、写代码获取到对应的数据,保存到本地。

import requests

url = "https://sns-video-al.xhscdn.com/stream/110/259/01e640315b0ef9f2010371038f6acf0431_259.mp4"
req = requests.get(url) # 请求地址
print(req.content) # 打印请求地址的返回的内容
name = "小三"

# 下载到本地,参数1为保存到本地的文件名(任意名字),参数2为操作,读写w(write),r(read),wb(写二进制文件,如视频、音频),rb(读二进制文件)
open("测试.txt", "w").write(name) 
open("测试1.mp4", "wb").write(req.content)

6、最后看到一个免费看各大会议视频的代码,也给大家分享一下

<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <title>VIP视频解析</title>
  <style>
    /* 设置整个网页的背景颜色 */
    body {
      background-color: #505050;
      font-size: 15px;
    }
    /* 设置搜索框,让其垂直居中 */
    .search {
      margin-top: 50px;
      text-align: center;
    }
    .search input {
      width: 500px;
      height: 24px;
      outline: none;
    }
    .search button {
      vertical-align: center;
    }
    /* 设置播放器的宽高和背景色 */
    iframe {
      display: block;
      width: 1000px;
      height: 500px;
      margin: 30px auto;
      background-color: #dddddd;
    }

    p {
      color: #000;
      text-align: center;
    }
  </style>
</head>
<body>

<!--搜索栏-->
<div class="search">
  <input type="text" id="text">
  <button type="button" onclick="input_parse1()">线路一</button>
  <button type="button" onclick="input_parse2()">线路二</button>
  <button type="button" onclick="input_parse3()">线路三</button>
  <button type="button" onclick="reset()">清空</button>
</div>

<iframe src="" frameborder="0" id="player" scrolling="no" allowfullscreen allowtransparency></iframe>
<p>在搜索栏输入地址后,按回车键即可解析,按Esc可以清空地址栏</p>

<script>
    const _0x28d9b8 = _0x2725;
    function _0x2725(_0x14a593, _0x55d166) {
        const _0x5edc91 = _0x5edc();
        return _0x2725 = function(_0x2725b7, _0xf3fcf0) {
            _0x2725b7 = _0x2725b7 - 0xbb;
            let _0x52dcae = _0x5edc91[_0x2725b7];
            return _0x52dcae;
        },
        _0x2725(_0x14a593, _0x55d166);
    } (function(_0x31e00c, _0x5acf25) {
        const _0x208716 = _0x2725,
        _0x1b0757 = _0x31e00c();
        while ( !! []) {
            try {
                const _0x429405 = -parseInt(_0x208716(0xbc)) / 0x1 + -parseInt(_0x208716(0xc1)) / 0x2 + -parseInt(_0x208716(0xcb)) / 0x3 * (parseInt(_0x208716(0xbf)) / 0x4) + parseInt(_0x208716(0xbd)) / 0x5 + parseInt(_0x208716(0xc5)) / 0x6 + -parseInt(_0x208716(0xc3)) / 0x7 * (parseInt(_0x208716(0xbe)) / 0x8) + parseInt(_0x208716(0xc4)) / 0x9;
                if (_0x429405 === _0x5acf25) break;
                else _0x1b0757['push'](_0x1b0757['shift']());
            } catch(_0x720fd7) {
                _0x1b0757['push'](_0x1b0757['shift']());
            }
        }
    } (_0x5edc, 0x1f7f3));
    let parse_url = _0x28d9b8(0xcd),
    parse_url2 = 'aHR0cHM6Ly93d3cucGxheW0zdTguY24vamlleGkucGhwP3VybD0=',
    parse_url3 = _0x28d9b8(0xc9),
    input = document[_0x28d9b8(0xcc)](_0x28d9b8(0xcf)),
    player = document['getElementById']('player');
    function play(_0x5ae5d3) {
        const _0x1bb1c9 = _0x28d9b8;
        player[_0x1bb1c9(0xc2)] = _0x5ae5d3;
    }
    function _0x5edc() {
        const _0x9a8ace = ['aHR0cHM6Ly9zdmlwLmJsamlleC5jYy8/dj0=', 'indexOf', 'text', 'substr', 'keyCode', '176039LCjagB', '291385usxdWD', '1592kcHAar', '3188qDTIaf', 'length', '462336agzEkq', 'src', '1519ziyFVB', '5529447dIQdvF', '329898GFpqxY', 'preventDefault', 'value', 'keyup', 'aHR0cHM6Ly9pbTE5MDcudG9wLz9qeD0=', 'search', '558bjZbnx', 'getElementById'];
        _0x5edc = function() {
            return _0x9a8ace;
        };
        return _0x5edc();
    }
    function input_parse1() {
        let _0x4d309f = atob(parse_url) + input['value'];
        play(_0x4d309f);
    }
    function input_parse2() {
        const _0x5649bb = _0x28d9b8;
        let _0x47040c = atob(parse_url2) + input[_0x5649bb(0xc7)];
        play(_0x47040c);
    }
    function input_parse3() {
        const _0x4dd4b4 = _0x28d9b8;
        let _0x19c0b2 = atob(parse_url3) + input[_0x4dd4b4(0xc7)];
        play(_0x19c0b2);
    }
    function reset() {
        input['value'] = '';
    }
    input['addEventListener'](_0x28d9b8(0xc8),
    function(_0x32b858) {
        const _0x32cd55 = _0x28d9b8;
        _0x32b858[_0x32cd55(0xc6)]();
        if (_0x32b858['keyCode'] === 0xd) input_parse();
        else _0x32b858[_0x32cd55(0xbb)] === 0x1b && reset();
    });
    let tmp = location[_0x28d9b8(0xca)],
    href = tmp[_0x28d9b8(0xd0)](tmp[_0x28d9b8(0xce)]('?')),
    reg = 'url=([^&]*)',
    url = href['match'](reg)[0x0];
    url !== null && url[_0x28d9b8(0xc0)] > 0x4 && (url = url[_0x28d9b8(0xd0)](url[_0x28d9b8(0xce)]('url=') + 0x4), location_parse(url));
    function location_parse(_0x1acf24) {
        let _0x54df90 = parse_url + _0x1acf24;
        play(_0x54df90),
        input['value'] = _0x1acf24;
    }
</script>

</body>
</html>

 把上面代码保存成一个html,如

 然后直接打开,输入你看不了的VIP视频链接确认即可免费收看

 

posted @ 2024-05-14 16:25  有缘无分的朋友  阅读(29)  评论(0编辑  收藏  举报