Bash 转换链接和下载图片的脚本

Bash script to transform links and download images

我想下载此图库中的所有壁纸:http://minus.com/mPxswm5Mn

谷歌搜索我发现我可以使用:

wget -r -A jpg http://minus.com/mPxswm5Mn

但是,该页面仅包含缩略图,link 的壁纸可以从中找到,如下所示:

Thumbnail url: i3.minus.com/jsyJQqqkzB66W_e.jpg

Wallpaper url: i3.minus.com/isyJQqqkzB66W.jpg

Thumbnail url: i1.minus.com/jNgnESZBOrhfk_e.jpg

Wallpaper url: i1.minus.com/iNgnESZBOrhfk.jpg

感谢任何帮助

这远非完美的解决方案,但您始终可以使用浏览器列出所有需要下载的文件,然后使用 wget 下载它们:

运行 您浏览器中的 javascript 片段:

var imgs = document.getElementsByClassName("grid_item_thumb");
var html = "";
for(var i=0; i<imgs.length; ++i) {
    html += imgs[i].src.replace(/\/j(.*)_e.jpg/, "/i.jpg") + ' ';
}
document.getElementsByTagName("body")[0].innerHTML = html;

对于你的特定页面,它会给你这个:

http://i1.minus.com/ibb1tmEYMJGWFT.jpg http://i1.minus.com/iNgnESZBOrhfk.jpg http://i3.minus.com/iitJZBqmXOYUq.jpg http://i3.minus.com/iyuCwEjztXsMF.jpg http://i2.minus.com/i0ZQNJf8vb6O2.jpg http://i2.minus.com/i6VRXhptiq1KU.jpg http://i5.minus.com/ib0H6MXLY4JeGL.jpg http://i1.minus.com/ibdwVqCRDKD8R7.jpg http://i3.minus.com/ievFZt5lDS0xy.jpg http://i4.minus.com/iHqfqOEkZDPo0.jpg http://i1.minus.com/iUe1SLFXjtyVe.jpg http://i1.minus.com/i8diPC08rFPIg.jpg http://i4.minus.com/isl4vklSl72pd.jpg http://i3.minus.com/isyJQqqkzB66W.jpg http://i7.minus.com/iriBAKsCaL92j.jpg http://i5.minus.com/im0ZKpI5FAHq0.jpg http://i2.minus.com/ilSVC7K8c0aXK.jpg http://i4.minus.com/ibmQ6r3h8SWYzI.jpg http://i3.minus.com/iVzu4QVH9azWW.jpg http://i2.minus.com/ijYWU36ege0Rr.jpg http://i1.minus.com/iQel0uLQK2Z4z.jpg http://i7.minus.com/ibk24biYBBYAeT.jpg http://i4.minus.com/ieGTVoAZaPbI2.jpg http://i2.minus.com/iuYThOzLn6XsF.jpg http://i2.minus.com/i0SAaVhrZZaL5.jpg http://i3.minus.com/ibztNp9L7zaU3F.jpg http://i5.minus.com/iJCl7B0bRahTr.jpg http://i5.minus.com/iR6Wa5uoxJFeA.jpg http://i2.minus.com/i5QHKNePLD9C0.jpg http://i3.minus.com/ibzAkM1IjGFHvR.jpg http://i2.minus.com/iqYYDjp83txiQ.jpg http://i6.minus.com/i6jFQkoAJYa1R.jpg http://i6.minus.com/ibrPBnHFyGEHQC.jpg http://i3.minus.com/iGzGyXBihCWcQ.jpg http://i4.minus.com/ibqwMh3mFNCirI.jpg http://i3.minus.com/ibvCZejMz05iH4.jpg http://i5.minus.com/iE85MKn3sMyqk.jpg http://i7.minus.com/ipixgQGKKkPw2.jpg http://i5.minus.com/iX5wooBBLIl39.jpg http://i4.minus.com/iNqvRAmIQAphd.jpg http://i6.minus.com/icj3SqCWVXDiV.jpg http://i4.minus.com/iblZFuq9kvs1Nf.jpg http://i1.minus.com/iigEYtFY87N0U.jpg http://i3.minus.com/ibtZHiIuJQTU6w.jpg http://i3.minus.com/iGujEMf2OfWIY.jpg http://i5.minus.com/ib0JPBn8i4VCNx.jpg http://i3.minus.com/ibvTyZm0l6MXiZ.jpg http://i1.minus.com/i5dJh4TYPx9bj.jpg http://i6.minus.com/ibrHdaADSSejvl.jpg http://i1.minus.com/ibcUJxQZCU49BF.jpg http://i1.minus.com/ixcoa5XdfgtCn.jpg http://i5.minus.com/ip52CdwKAz2bR.jpg http://i2.minus.com/i5KMTx22lA7bP.jpg http://i5.minus.com/iuDulPAkX9CGk.jpg http://i5.minus.com/iB3sqxh7pIuH9.jpg http://i5.minus.com/i20DFIO4GVB1h.jpg http://i6.minus.com/ibhcAIwJ8AYgJR.jpg http://i5.minus.com/ioCdy2IZSqmWx.jpg http://i3.minus.com/iby48bA5K2GP0L.jpg http://i1.minus.com/iPfaYCDuz9xwz.jpg http://i2.minus.com/inO9GQr6450Bv.jpg http://i2.minus.com/iiYxzaAKpa6A4.jpg http://i1.minus.com/ibaaCqAGnT5CAu.jpg http://i7.minus.com/ibkc4xjbf0yKEG.jpg http://i5.minus.com/iuDW7LnAKqWrf.jpg http://i5.minus.com/ib1TTRbjEOrVsd.jpg http://i1.minus.com/ivfdsnDvOm0As.jpg http://i2.minus.com/iFR7E3cVR7vFM.jpg http://i2.minus.com/iGRxohksNdi1H.jpg http://i2.minus.com/iGVYyjaP9DWgs.jpg http://i1.minus.com/ibd34cjNZysV9D.jpg http://i6.minus.com/ibhFhdBswSdRbl.jpg http://i4.minus.com/iGqdr0L18P3Kr.jpg http://i5.minus.com/iCEZ5T4sUDjHi.jpg http://i7.minus.com/ivBTUAk6cK26L.jpg http://i2.minus.com/ifO73LUD5tgQp.jpg http://i5.minus.com/i98v2HTQgcjcb.jpg http://i2.minus.com/iFLa4Zo1u8KOu.jpg http://i3.minus.com/iDzGoaFEbOK3X.jpg http://i4.minus.com/ibqzS9GS4z7gCD.jpg http://i4.minus.com/iblogFe9Op8tFk.jpg http://i4.minus.com/i5nnZ6wXLHtgn.jpg http://i4.minus.com/iCpWjYy07z7S1.jpg http://i4.minus.com/iKnkXFPRZB7W.jpg http://i3.minus.com/iby6Dg1zpdY1in.jpg http://i7.minus.com/iABhWmq0upnuz.jpg http://i4.minus.com/ibn52BzbDsG4L5.jpg http://i2.minus.com/icOC6xjysZVpu.jpg http://i4.minus.com/ism8wP4XNCW7M.jpg http://i3.minus.com/iby5hJlpTlO1I3.jpg http://i6.minus.com/ihILTGiearIR6.jpg http://i2.minus.com/idYS2bhiPdDc3.jpg http://i6.minus.com/iOj9Omn6HEnYv.jpg http://i4.minus.com/iMmgVQAXqrg4Q.jpg http://i4.minus.com/ibpZhkaaPzDtWU.jpg http://i1.minus.com/ibaOlHIsx0iJMS.jpg http://i6.minus.com/iyrZSX5TswnDk.jpg http://i3.minus.com/ibujJB04GxWwvO.jpg http://i4.minus.com/ibor2bgtCBjMp3.jpg http://i5.minus.com/ij1JjMySkCATm.jpg http://i3.minus.com/ivxToOWGkXko4.jpg http://i4.minus.com/ibllcqgDcJ8ess.jpg http://i6.minus.com/ixji9sK26KiAT.jpg http://i4.minus.com/iboh6KjVVXlIV7.jpg http://i7.minus.com/ibsod54BAoswvp.jpg http://i2.minus.com/ihRIt03KJasW0.jpg http://i4.minus.com/iMnPTCNhtyhtv.jpg

然后您可以将其复制粘贴到控制台并使用 wget 下载图像:

wget http://i1.minus.com/ibb1tmEYMJGWFT.jpg http://i1.minus.com/iNgnESZBOrhfk.jpg http://i3.minus.com/iitJZBqmXOYUq.jpg http://i3.minus.com/iyuCwEjztXsMF.jpg http://i2.minus.com/i0ZQNJf8vb6O2.jpg http://i2.minus.com/i6VRXhptiq1KU.jpg http://i5.minus.com/ib0H6MXLY4JeGL.jpg http://i1.minus.com/ibdwVqCRDKD8R7.jpg http://i3.minus.com/ievFZt5lDS0xy.jpg http://i4.minus.com/iHqfqOEkZDPo0.jpg http://i1.minus.com/iUe1SLFXjtyVe.jpg http://i1.minus.com/i8diPC08rFPIg.jpg http://i4.minus.com/isl4vklSl72pd.jpg http://i3.minus.com/isyJQqqkzB66W.jpg http://i7.minus.com/iriBAKsCaL92j.jpg http://i5.minus.com/im0ZKpI5FAHq0.jpg http://i2.minus.com/ilSVC7K8c0aXK.jpg http://i4.minus.com/ibmQ6r3h8SWYzI.jpg http://i3.minus.com/iVzu4QVH9azWW.jpg http://i2.minus.com/ijYWU36ege0Rr.jpg http://i1.minus.com/iQel0uLQK2Z4z.jpg http://i7.minus.com/ibk24biYBBYAeT.jpg http://i4.minus.com/ieGTVoAZaPbI2.jpg http://i2.minus.com/iuYThOzLn6XsF.jpg http://i2.minus.com/i0SAaVhrZZaL5.jpg http://i3.minus.com/ibztNp9L7zaU3F.jpg http://i5.minus.com/iJCl7B0bRahTr.jpg http://i5.minus.com/iR6Wa5uoxJFeA.jpg http://i2.minus.com/i5QHKNePLD9C0.jpg http://i3.minus.com/ibzAkM1IjGFHvR.jpg http://i2.minus.com/iqYYDjp83txiQ.jpg http://i6.minus.com/i6jFQkoAJYa1R.jpg http://i6.minus.com/ibrPBnHFyGEHQC.jpg http://i3.minus.com/iGzGyXBihCWcQ.jpg http://i4.minus.com/ibqwMh3mFNCirI.jpg http://i3.minus.com/ibvCZejMz05iH4.jpg http://i5.minus.com/iE85MKn3sMyqk.jpg http://i7.minus.com/ipixgQGKKkPw2.jpg http://i5.minus.com/iX5wooBBLIl39.jpg http://i4.minus.com/iNqvRAmIQAphd.jpg http://i6.minus.com/icj3SqCWVXDiV.jpg http://i4.minus.com/iblZFuq9kvs1Nf.jpg http://i1.minus.com/iigEYtFY87N0U.jpg http://i3.minus.com/ibtZHiIuJQTU6w.jpg http://i3.minus.com/iGujEMf2OfWIY.jpg http://i5.minus.com/ib0JPBn8i4VCNx.jpg http://i3.minus.com/ibvTyZm0l6MXiZ.jpg http://i1.minus.com/i5dJh4TYPx9bj.jpg http://i6.minus.com/ibrHdaADSSejvl.jpg http://i1.minus.com/ibcUJxQZCU49BF.jpg http://i1.minus.com/ixcoa5XdfgtCn.jpg http://i5.minus.com/ip52CdwKAz2bR.jpg http://i2.minus.com/i5KMTx22lA7bP.jpg http://i5.minus.com/iuDulPAkX9CGk.jpg http://i5.minus.com/iB3sqxh7pIuH9.jpg http://i5.minus.com/i20DFIO4GVB1h.jpg http://i6.minus.com/ibhcAIwJ8AYgJR.jpg http://i5.minus.com/ioCdy2IZSqmWx.jpg http://i3.minus.com/iby48bA5K2GP0L.jpg http://i1.minus.com/iPfaYCDuz9xwz.jpg http://i2.minus.com/inO9GQr6450Bv.jpg http://i2.minus.com/iiYxzaAKpa6A4.jpg http://i1.minus.com/ibaaCqAGnT5CAu.jpg http://i7.minus.com/ibkc4xjbf0yKEG.jpg http://i5.minus.com/iuDW7LnAKqWrf.jpg http://i5.minus.com/ib1TTRbjEOrVsd.jpg http://i1.minus.com/ivfdsnDvOm0As.jpg http://i2.minus.com/iFR7E3cVR7vFM.jpg http://i2.minus.com/iGRxohksNdi1H.jpg http://i2.minus.com/iGVYyjaP9DWgs.jpg http://i1.minus.com/ibd34cjNZysV9D.jpg http://i6.minus.com/ibhFhdBswSdRbl.jpg http://i4.minus.com/iGqdr0L18P3Kr.jpg http://i5.minus.com/iCEZ5T4sUDjHi.jpg http://i7.minus.com/ivBTUAk6cK26L.jpg http://i2.minus.com/ifO73LUD5tgQp.jpg http://i5.minus.com/i98v2HTQgcjcb.jpg http://i2.minus.com/iFLa4Zo1u8KOu.jpg http://i3.minus.com/iDzGoaFEbOK3X.jpg http://i4.minus.com/ibqzS9GS4z7gCD.jpg http://i4.minus.com/iblogFe9Op8tFk.jpg http://i4.minus.com/i5nnZ6wXLHtgn.jpg http://i4.minus.com/iCpWjYy07z7S1.jpg http://i4.minus.com/iKnkXFPRZB7W.jpg http://i3.minus.com/iby6Dg1zpdY1in.jpg http://i7.minus.com/iABhWmq0upnuz.jpg http://i4.minus.com/ibn52BzbDsG4L5.jpg http://i2.minus.com/icOC6xjysZVpu.jpg http://i4.minus.com/ism8wP4XNCW7M.jpg http://i3.minus.com/iby5hJlpTlO1I3.jpg http://i6.minus.com/ihILTGiearIR6.jpg http://i2.minus.com/idYS2bhiPdDc3.jpg http://i6.minus.com/iOj9Omn6HEnYv.jpg http://i4.minus.com/iMmgVQAXqrg4Q.jpg http://i4.minus.com/ibpZhkaaPzDtWU.jpg http://i1.minus.com/ibaOlHIsx0iJMS.jpg http://i6.minus.com/iyrZSX5TswnDk.jpg http://i3.minus.com/ibujJB04GxWwvO.jpg http://i4.minus.com/ibor2bgtCBjMp3.jpg http://i5.minus.com/ij1JjMySkCATm.jpg http://i3.minus.com/ivxToOWGkXko4.jpg http://i4.minus.com/ibllcqgDcJ8ess.jpg http://i6.minus.com/ixji9sK26KiAT.jpg http://i4.minus.com/iboh6KjVVXlIV7.jpg http://i7.minus.com/ibsod54BAoswvp.jpg http://i2.minus.com/ihRIt03KJasW0.jpg http://i4.minus.com/iMnPTCNhtyhtv.jpg

或者,正如 Enissay 所指出的,可以将 url 保存到文件中并像这样下载:

wget -i urls.txt

如果你运气好,你可以随时尝试 download all files from your browser using only javascript