Untitled

 avatar
user_2299906
plain_text
a year ago
1.1 kB
2
Indexable
Never
    public void DownloadFile(string url, string pathfile, string referer = "https://www.facebook.com/")
        {
            try
            {
                RestRequest request = new RestRequest(url);
                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");
                request.AddHeader("referer", referer);
                request.AddHeader("sec-ch-ua-platform", "\"Windows\"");
                request.Method = Method.Get;                
                var temp = Client.DownloadDataAsync(request).Result;
                if (temp != null)
                    File.WriteAllBytes(pathfile, temp);

            }
            catch (Exception ex)
            {
                
            }

        }