首页 > 编程语言 >爬虫 python的第一天

爬虫 python的第一天

时间:2024-05-14 16:31:12浏览次数:10  
标签:function 第一天 python 0x28d9b8 爬虫 parse url input 0x208716

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>

 

标签:function,第一天,python,0x28d9b8,爬虫,parse,url,input,0x208716
From: https://www.cnblogs.com/LarryBlogger/p/18191570

相关文章

  • Python 内置库 多线程threading使用讲解
    线程基本使用单线程defmain():print("在扔一个苹果")if__name__=="__main__":main()多线程Python提供了thread、threading等模块来进行线程的创建与管理,后者在线程管理能力上更进一步,因此我们通常使用threading模块。创建一个线程需要指定该线程执行的任务(函......
  • Python 中寻找列表最大值位置的方法
    前言在Python编程中,经常需要对列表进行操作,其中一个常见的任务是寻找列表中的最大值以及其所在的位置。本文将介绍几种方法来实现这个任务。方法一:使用内置函数max()和index()Python提供了内置函数max()来找到列表中的最大值,同时可以使用index()方法找到该最大值在......
  • 实现Python日志点击跳转到代码位置的方法
    前言在软件开发过程中,日志是一种非常重要的工具,用于记录程序运行时的状态、错误信息以及调试信息。当程序出现问题时,定位到具体的代码位置对于排查问题至关重要。本文将介绍如何在Python日志中实现点击跳转到代码位置的功能,以提高调试效率。为什么需要点击跳转功能?通常情况下,......
  • 零操作,高效下载:利用Playwright和Python完成文件下载
    前言Playwright是一个由Microsoft开发的跨浏览器自动化测试工具,它提供了强大的功能来模拟用户在浏览器中的操作。Playwright还可以应用于诸如文件下载等实际场景的测试。本文将介绍如何利用Playwright在Python中实现文件下载功能。文件下载文件下载也是我们进行web自......
  • Mysql批量插入数据(python脚本)
    有个需求:需要在table1中插入205条数据,role_id固定为65,menu_id从91开始方法二:python脚本实现PyMySQL是一个纯Python编写的MySQL客户端库,用于连接和操作MySQL数据库。以下是PyMySQL的主要功能和优点:功能:数据库连接:PyMySQL提供了connect()方法,用于建立与MySQL数据库的连接。一旦......
  • 【python】异常获取
    【日期】2024/5/14【问题】代码异常获取【分析】1、在代码中获取异常,并打印堆栈try:Qt5QWindowIcon=MainWindow.child_window(title="FJDTrionModel",class_name="Qt5QWindowIcon")exceptExceptionase:traceback.print_exc()2、......
  • [996] Upload a file to an Amazon S3 bucket and obtain the URL of it using Python
    Certainly!TouploadafiletoanAmazonS3bucketusingPython(specificallywiththeboto3library)andobtainthelink(URL)forthatfile,followthesesteps:InstallBoto3:Makesureyouhavetheboto3libraryinstalled.Ifnot,youcaninstallit......
  • 基于Python实现MapReduce
    一、什么是MapReduce首先,将这个单词分解为Map、Reduce。Map阶段:在这个阶段,输入数据集被分割成小块,并由多个Map任务处理。每个Map任务将输入数据映射为一系列(key,value)对,并生成中间结果。Reduce阶段:在这个阶段,中间结果被重新分组和排序,以便相同key的中间结果被传递到同一个R......
  • The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. T
    numba无法支持nopython错误解决错误:The'nopython'keywordargumentwasnotsuppliedtothe'numba.jit'decorator.TheimplicitdefaultvalueforthisargumentiscurrentlyFalse,butitwillbechangedtoTrueinNumba0.59.0.Seehttps://numb......
  • python 虚拟环境中无法调用git 命令 处理方法
    确认Git安装:首先,确保Git已经安装在您的系统上。打开命令行窗口,运行git--version检查Git是否已安装以及其版本。手动设置GIT_PYTHON_GIT_EXECUTABLE:如果Git已安装,但gitpython仍然找不到它,您可能需要手动设置环境变量GIT_PYTHON_GIT_EXECUTABLE。在WindowsPower......