javascript下载需要引用的图像
当我尝试使用javascript下载时,我想要下载的图像返回403 但我可以下载带有python代码的图像,如下所示。它将referer添加到标题并下载javascript下载需要引用的图像,javascript,python,imagedownload,Javascript,Python,Imagedownload,当我尝试使用javascript下载时,我想要下载的图像返回403 但我可以下载带有python代码的图像,如下所示。它将referer添加到标题并下载 req = urllib.request.Request(image_url, headers={"Referer": referer_url}) with urllib.request.urlopen(req) as response, open("image.jpg", "wb") as outfile: shutil.copyfi
req = urllib.request.Request(image_url, headers={"Referer": referer_url})
with urllib.request.urlopen(req) as response, open("image.jpg", "wb") as outfile:
shutil.copyfileobj(response, outfile)
javascript可以像这样下载图像吗
我正在尝试使用的Javascript代码。它的反应是把图书馆弄得乱七八糟
export const saveToonImageToLocal = (url, imageName) => {
return RNFetchBlob
.config({
path: dirs.DocumentDir + `${imageName}.jpg`,
appendExt: 'jpg'
})
.fetch('GET', url, {})
.then((res)=>{
return res.path();
})
.catch((e)=>{
console.log('error occurend during saving images');
})
};
您可以使用javascript ajax调用加载图像并在其中传递头:
$.ajax({
type:'GET',
url:'https://example.com/someimage.png',
headers: {'Referer': "http://somepage.com"},
success:function(data){
$('#someImage').attr('src',data);
}
});
你能把你正在使用的Javascript添加到你的问题中吗?可能是重复的