// 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);
}
});
The script above pulls in an address, email, and phone number from a website. How can i simply save this data that i pull in to a text file?
Im trying to do this but without having a to use a click event
As far as I can tell, neither Firefox nor Chrome requires that the code in your linked article's saveTextAsFile
be run in response to a user event. (Which is horrifying and almost certainly a bug.) So just adapt the example so you call saveTextAsFile
from within your ajax
completion handler.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.