1
Reply

Problem accessing link by using HttpWebRequest or WebBrowser

adi adi

adi adi

Apr 21 2012 1:12 PM
1.5k
Hello,

I have problem accessing links from a website. The site is  http://www.tv-links.eu/tv-shows/A.html and a link that I need to access looks like this in html code :  <a href="/tv-shows/Absolute-Power_25833/" class="list cfix"> <span class="c1">Absolute Power</span> <span class="c2">2003</span> </a> . 

I try to access this link by forming the complete address : http://www.tv-links.eu/tv-shows/Absolute-Power_25833/, but when using either the  HttpWebRequest class or the WebBrowser class, the page that is opened is the main page of the site, and not the one I give as a link.

Here is the code I use for  HttpWebRequest  : 
                //request to access the link
                HttpWebRequest webReq = (HttpWebRequest)HttpWebRequest.Create(new Uri(link));

                //the response
                HttpWebResponse webRes = (HttpWebResponse)webReq.GetResponse();

                //gets the stream of data from the response
                Stream streamResponse = webRes.GetResponseStream();
                StreamReader sr = new StreamReader(streamResponse);

                content = sr.ReadToEnd();
                sr.Close();
                streamResponse.Close();

And for the webBrowser:
this.webBrowserForNavigation.Navigate(link);

Can someone offer instructions on how to access the intended link ?

Thank you.

Answers (1)