0

Please see the codes below :

    string getData = "";

    HttpWebRequest req = (HttpWebRequest)WebRequest.Create("A Web Site");
    req.Method = "GET";
    req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
    req.UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20100101 Firefox/15.0";
    req.ContentType = "text/html; charset=utf-8";
    req.Referer = "That Web Site Referer";
    req.KeepAlive = true;

    req.CookieContainer = cookieJar;

    HttpWebResponse res = (HttpWebResponse)req.GetResponse();

    Stream Stream = res.GetResponseStream();
    StreamReader reader = new StreamReader(Stream);
    string reader_str = reader.ReadToEnd();

After running these codes we have a source web page string in reader_str.
how can i click on a link(with specific id) in reader_str & get that click responce again like upper codes?
should i use webBrowser or HtmlAgilityPack?
would you please show me the fastest way!

EDIT :
That link is not in access. There is an image with a javascript function(onclick of that image). after click on that image that js fn makes an url and couses postback. i should click on that image...

thanks in advance

SilverLight
  • 19,668
  • 65
  • 192
  • 300
  • http://stackoverflow.com/questions/6063203/parsing-html-with-c-net – Anant Dabhi Sep 14 '12 at 11:42
  • thanks for that link -> but how can i do this using HtmlAgilityPack -> InvokeMember("click") -> and how can i grab that click's responce again? – SilverLight Sep 14 '12 at 11:48
  • http://runtingsproper.blogspot.com/2009/09/htmlagilitypack-article-series.html [other example]http://runtingsproper.blogspot.com/2009/09/introduction-to-htmlagilitypack-library.html other one http://runtingsproper.blogspot.com/2009/11/easily-extracting-links-from-snippet-of.html – Anant Dabhi Sep 14 '12 at 11:58
  • @Anant Dabhi, really thanks for your useful links. please see my edit. – SilverLight Sep 14 '12 at 12:50

1 Answers1

1

Probalbly you can build a Regex for extracting hrefs of anchor with specific id and then fire up HttpWebRequest again for extracted href.

Agent007
  • 2,720
  • 3
  • 20
  • 24
  • Thanks For The Answer / But that link is not in access. There is an image with a javascript function(onclick of that image). after click on that image that js fn makes an url and couses postback. i should click on that image and this is why i asked this q... – SilverLight Sep 14 '12 at 12:45