Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 655

New Post: problem : using htmlagilitypack with c#

$
0
0

problem : using htmlagilitypack with c#


problem : using htmlagilitypack with c#

I can not use the [ htmlagilitypack with c# ] to enter page protected with username and password.

if i use that code directly i have to use username and password to access this page , how i can use it with HtmlWeb ????

var getInfo = new HtmlWeb();
 var info= getInfo.Load("http://www.mysite.com/page.php");
 var userName = info.DocumentNode.SelectNodes("//div[@class='username']");
 if (userName != null) {

String uname= gotoAdventure[0].InnerText; MessageBox.Show(uname);

}

The previous method does not work



i use that code to request that page and pass (username and password) and then save that
response to temp.tmp file and then using HtmlWeb to load that file and getting the information , and that method is very bad and ineffective

sendGetRequest("http://www.mysite.com/page.php?username=ali&password=123123");
var getInfo = new HtmlWeb();
var info= getInfo.Load("e:/temp.tmp");


The previous method does not work



i use that code to request that page and pass (username and password) and then save that
response to temp.tmp file and then using HtmlWeb to load that file and getting the information , and that method is very bad and ineffective

sendGetRequest("http://www.mysite.com/page.php?username=ali&password=123123"

);

var getInfo = new HtmlWeb();
var info= getInfo.Load("e:/temp.tmp");
 

 

 public static void sendGetRequest(string link) {

 Random r = new Random(((int)DateTime.Now.Ticks));
 string filename = CreateRandomFileName(5, r);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(link);
request.Method = "GET";
request.KeepAlive = true;
request.CookieContainer = cookies;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
 Stream receiveStream = response.GetResponseStream();
 StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
TextWriter tW = new StreamWriter("e:/temp.tmp");
 tW.Write(readStream.ReadToEnd());
tW.Close();

}

how i can slove the problem , and using htmlagilitypack without save any file ???
 

Viewing all articles
Browse latest Browse all 655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>