我准备了一个小型网站,可以从instagram下载照片。我在源代码中找到了jpg链接,但我不知道如何将其转换为下载链接。
我还想在找到链接后立即下载链接(不是单击事件)。我当前的代码:
function link()
{
for (var i= licznik;i<data.length;i++) //data is a response text(XMLHTTP)
{
kod=kod+data[i];
if(data[i+2]== " ")
{
console.log(kod); //it works(returning correct url for example: https://something.jpg)
Pobierz(); // this function has to call a download
break;
}
}
console.log(kod);
}
function Pobierz()
{
var link;
link.href = string(kod); // error
link.click(); // i don't want onclick - it has to be downloaded when function is called
}