A
AD_AE
Guest
Hello,
I have a huge amount of deviantart links in my bookmarks and I want to donwload them.
I created this program to do it but after just a few download I get the error 403: Forbidden (i tried a infinite loop that leaves when the error stop but it seems that after get it, it wont leave)
How can I solve this?
WebClient client = new WebClient();
client.Headers.Add("Accept", "text / html, application / xhtml + xml, image / jxr, */*");
client.Headers.Add("Accept-Language", "pt - PT, pt; q = 0.8, en - US; q = 0.5, en; q = 0.3");
client.Headers.Add("Cookie", "_ga = GA1.3.1173403303.1470761279; tw =% 7B % 22browse % 22 % 3A1134 % 7D; userinfo = __01658d30ffdd0b479894 % 3B % 7B % 22username % 22 % 3A % 22 % 22 % 2C % 22uniqueid % 22 % 3A % 22a5dc80fe2a7aa790049fced4be5d0f39 % 22 % 2C % 22vd % 22 % 3A % 22BXqgk9 % 2CBYJFwd % 2CA % 2CS % 2CA % 2C % 2CL % 2CB % 2CB % 2CBYJJOx % 2CBYJJhI % 2CO % 2CD % 2CJ % 2CBYJJhI % 2C13 % 2CA % 2CB % 2CA % 2C % 2CB % 2CA % 2CB % 2CA % 2CA % 2C % 2CA % 22 % 2C % 22attr % 22 % 3A67108880 % 7D; _ga = GA1.2.1173403303.1470761279; __qca = P0 - 724951276 - 1470761281462; __gads = ID = f00ea51d533ffef6:T = 1472910412:S = ALNI_MZThZH7YlaHm_VKaQ_TH2Hik7nsmQ; _gat = 1");
client.Headers.Add("DNT", "1");
client.Headers.Add("Host", "backend.deviantart.com");
client.Headers.Add("User-Agent", "Mozilla / 5.0(Windows NT 10.0; Win64; x64) AppleWebKit / 537.36(KHTML, like Gecko) Chrome / 51.0.2704.79 Safari / 537.36 Edge / 14.14393");
foreach (var item in noDupes) //noDupes is the list with all the links
{
string url = item; // any deviantart image page
string infoUrl = "http://backend.deviantart.com/oembed?url=" + url + "&format=xml"; // omit the format to get json
//403 here (it work at start and then the error comes
//sometimes it downloads 1 2 imgs but most of the time it can download around 26 and then error appears
string infoText = client.DownloadString(infoUrl); // get xml using System.Net.WebClient
XDocument doc = XDocument.Parse(infoText); // parse xml
var element = doc.Descendants().Where(cur => cur.Name.LocalName == "url").First(); // find <url> element
string imgUrl = element.Value.Replace("/PRE/", "/"); // change the url into get the high-res image
var result = imgUrl.Substring(imgUrl.LastIndexOf(/) + 1);
Console.WriteLine(imgUrl);
client.DownloadFile(new Uri(imgUrl), @"C:\Users\adae\Desktop\DeviantartImages\" + result);
}
How can I solve this? (the headers i took from Edge programmers tool (tried with the crhome ones too)
Best Regards,
ADAE.
Continue reading...
I have a huge amount of deviantart links in my bookmarks and I want to donwload them.
I created this program to do it but after just a few download I get the error 403: Forbidden (i tried a infinite loop that leaves when the error stop but it seems that after get it, it wont leave)
How can I solve this?
WebClient client = new WebClient();
client.Headers.Add("Accept", "text / html, application / xhtml + xml, image / jxr, */*");
client.Headers.Add("Accept-Language", "pt - PT, pt; q = 0.8, en - US; q = 0.5, en; q = 0.3");
client.Headers.Add("Cookie", "_ga = GA1.3.1173403303.1470761279; tw =% 7B % 22browse % 22 % 3A1134 % 7D; userinfo = __01658d30ffdd0b479894 % 3B % 7B % 22username % 22 % 3A % 22 % 22 % 2C % 22uniqueid % 22 % 3A % 22a5dc80fe2a7aa790049fced4be5d0f39 % 22 % 2C % 22vd % 22 % 3A % 22BXqgk9 % 2CBYJFwd % 2CA % 2CS % 2CA % 2C % 2CL % 2CB % 2CB % 2CBYJJOx % 2CBYJJhI % 2CO % 2CD % 2CJ % 2CBYJJhI % 2C13 % 2CA % 2CB % 2CA % 2C % 2CB % 2CA % 2CB % 2CA % 2CA % 2C % 2CA % 22 % 2C % 22attr % 22 % 3A67108880 % 7D; _ga = GA1.2.1173403303.1470761279; __qca = P0 - 724951276 - 1470761281462; __gads = ID = f00ea51d533ffef6:T = 1472910412:S = ALNI_MZThZH7YlaHm_VKaQ_TH2Hik7nsmQ; _gat = 1");
client.Headers.Add("DNT", "1");
client.Headers.Add("Host", "backend.deviantart.com");
client.Headers.Add("User-Agent", "Mozilla / 5.0(Windows NT 10.0; Win64; x64) AppleWebKit / 537.36(KHTML, like Gecko) Chrome / 51.0.2704.79 Safari / 537.36 Edge / 14.14393");
foreach (var item in noDupes) //noDupes is the list with all the links
{
string url = item; // any deviantart image page
string infoUrl = "http://backend.deviantart.com/oembed?url=" + url + "&format=xml"; // omit the format to get json
//403 here (it work at start and then the error comes
//sometimes it downloads 1 2 imgs but most of the time it can download around 26 and then error appears
string infoText = client.DownloadString(infoUrl); // get xml using System.Net.WebClient
XDocument doc = XDocument.Parse(infoText); // parse xml
var element = doc.Descendants().Where(cur => cur.Name.LocalName == "url").First(); // find <url> element
string imgUrl = element.Value.Replace("/PRE/", "/"); // change the url into get the high-res image
var result = imgUrl.Substring(imgUrl.LastIndexOf(/) + 1);
Console.WriteLine(imgUrl);
client.DownloadFile(new Uri(imgUrl), @"C:\Users\adae\Desktop\DeviantartImages\" + result);
}
How can I solve this? (the headers i took from Edge programmers tool (tried with the crhome ones too)
Best Regards,
ADAE.
Continue reading...