This project has moved. For the latest updates, please go here.

Programmatically login in another site in ASP.Net

Topics: Developer Forum, Project Management Forum, User Forum
Jul 30, 2007 at 6:39 AM
hi sir
i need to login programattically and scrapping data from a website which is the next page after login .
for this i m using html agility pack.
i m using the link
as reference .
for trial i m trying to login in gmail and code is as following........................
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
FormProcessor p = new FormProcessor();
string userName = "*****************";
string password = "******************";
Form form = p.GetForm("","//form@name='loginForm'", FormQueryModeEnum.Nested);
form"j_username".SetAttributeValue("value", userName);
form"j_password".SetAttributeValue("value", password);
HtmlDocument doc = p.SubmitForm(form);
string strBal = doc.DocumentNode.SelectSingleNode
strBal = System.Web.HttpUtility.HtmlDecode(strBal);
strBal = strBal.Substring(1).Trim();

in which i m facing problem in xpath //form@name='loginForm' the error is node not found.
i want to know that how can i compose the xpath for any website . plz tell me complete reference about it.

thanks in advance

sharad soni