繁体   English   中英

将数据保存到本地文本文件

[英]Saving data to a local text file

// Queries atlatlsoftware.com and returns the site in json data format, using YQL
$.ajax({
    url: "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fatlatlsoftware.com%22%20and%0A%20%20%20%20%20%20xpath%3D'%2F%2F*%5B%40id%3D%22desktop-footer%22%5D%2Fdiv%5B3%5D%2Fdiv%2Ftable%2Ftbody%2Ftr%5B2%5D%2Ftd%5B1%5D'&format=json&diagnostics=true&callback=?",
    dataType: 'jsonp',
    // upon success, logs the data as "response"
    success: function (response) {

        // simply following the json data path and assigning it to a variable
        var address = response.query.results.td.div[1].content;
        var phone = response.query.results.td.div[2];
        var email = response.query.results.td.div[3];
        // var tweet = response.query.results;

        // appends the variable to the html
        $(".address").html(address);
        $(".phone").html(phone);
        $(".email").html(email);
        console.log(address);
        console.log(phone);
        console.log(email);
        // console.log(tweet);

    }
});

上面的脚本从网站提取地址,电子邮件和电话号码。 如何简单地保存输入到文本文件中的数据?

我试图做到这一点,但不必使用click事件

据我所知,Firefox和Chrome都不需要运行链接文章的saveTextAsFile中的代码来响应用户事件。 (这令人恐惧,几乎肯定是一个错误。)因此,只需修改示例, saveTextAsFileajax完成处理程序中调用saveTextAsFile

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM