Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.1 kB
14
Indexable
Never
   public void DownloadFile(string url, string pathfile)
        {
            try
            {
                RestRequest request = new RestRequest(url);
                request.AddHeader("User-Agent", UA);
                request.AddHeader("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9");
                request.AddHeader("sec-fetch-site", "same-origin");
                request.AddHeader("sec-fetch-dest", "empty");
                request.AddHeader("accept-language", "en-US,en;q=0.9");
                request.AddHeader("sec-fetch-mode", "cors");
                if (!string.IsNullOrEmpty(referer))
                    request.AddHeader("referer", referer);
                request.AddHeader("sec-ch-ua-platform", "\"Windows\"");
                request.Method = Method.Get;
                var temp = Client.DownloadData(request);
                if (temp != null)
                    File.WriteAllBytes(pathfile, temp);
            }
            catch 
            {
                
            }
        }
Leave a Comment