zoukankan      html  css  js  c++  java
  • 将chrome页面的变量保存到本地

    在chrome的控制台中粘贴并运行如下代码:

    (function(console) {
        console.save = function(data, filename) {
            if (!data) {
                console.error('Console.save: No data')
                return;
            }
            if (!filename) filename = 'console.json'
            if (typeof data === 'object') {
                data = JSON.stringify(data, undefined, 4)
            }
            var blob = new Blob([data], {
                    type: 'text/json'
                }),
                e = document.createEvent('MouseEvents'),
                a = document.createElement('a')
            a.download = filename
            a.href = window.URL.createObjectURL(blob)
            a.dataset.downloadurl = ['text/json', a.download, a.href].join(':')
            e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
            a.dispatchEvent(e)
        }
        return 'success'
    })(console)

    使用范例:

    然后运行如下代码:

    fetch('https://feed.sina.com.cn/api/roll/get?pageid=121&lid=1356&num=20&versionNumber=1.2.4&page=125&encode=utf-8&_=1600564853163')
        .then(res=>{
            res.json().then(r=>{
                console.save(r, 'result.json')
            })
        });
  • 相关阅读:
    Vue-嵌套路由
    Vue-详解设置路由导航的两种方法: <router-link :to="..."> 和router.push(...)
    Python
    windows和linux下 Python2,Python3 的环境及安装
    Python那点事
    Linux
    Linux
    Django
    Redis
    Django
  • 原文地址:https://www.cnblogs.com/springwind2006/p/13698861.html
Copyright © 2011-2022 走看看