[英]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
中的代碼來響應用戶事件。 (這令人恐懼,幾乎肯定是一個錯誤。)因此,只需修改示例, saveTextAsFile
從ajax
完成處理程序中調用saveTextAsFile
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.