Search code examples
c#webrequest

Run a URL and get the new link


I want to run a URL and get the result. I used the below code but it does not work correctly. It just returns the main website URL as a result. this is the main page which has a blue box is called filenext. I get its link and this is what I want to get as a result.

                    WebClient client = new WebClient();
                    client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
                    WebClient getNitroflareLink = new WebClient();


                    HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
                    HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                    Stream stream = response.GetResponseStream();

Solution

  • You should set Refererfrom the first URL for the second one.

            var page = firstLink.LoadIt();
                HttpWebRequest request = WebRequest.Create(Refererlink) as HttpWebRequest;
                request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36";
                request.Referer = firstLink;
                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)