|
-
December 13th, 2010, 12:03 PM
#1
communicating with facebook problem
Hi,
I'm trying to collect facebook user IDs from a page using webbrowser control in c#, the problem is that it always collects the same amount of users although there are more on that page. What I actually do is scan the source code for "user.php?id=" and perform a substring to take out the user id and name but I found out that not all the users appear in the page source. and the second problem is that when I collect user IDs it always gets me the same users even when I browse other pages, only when I use webbrowser.navigate(); it changes, anyone knows how to make it update itself automatically or smth else?
this is the code that I used to collect the user IDs:
Code: (I know it's not the BEST but take it easy on me im kinda new)
private void button1_Click_1(object sender, EventArgs e)
{
string MainString = webBrowser1.DocumentText;
string SrchStrId = "user.php?id=";
string SrchStrIdE = "\"";
string SrchStrName = "\">";
string SrchStrNameE = "<";
string strId;
string strName;
int FirstChr;
int EndChr;
ArrayList idList = new ArrayList();
ArrayList NameList = new ArrayList();
ArrayList boxlist = new ArrayList();
while (MainString.IndexOf(SrchStrId) > -1)
{
FirstChr = MainString.IndexOf(SrchStrId);
MainString = MainString.Substring(FirstChr);
EndChr = MainString.IndexOf(SrchStrIdE);
strId = MainString.Substring(SrchStrId.Length, EndChr - SrchStrId.Length);
if(strId.EndsWith("\\"))
{
strId=strId.Remove(strId.Length - 1, 1);
}
strName = MainString;
FirstChr = strName.IndexOf(SrchStrName);
EndChr = strName.IndexOf(SrchStrNameE);
strName = strName.Substring(FirstChr);
strName = strName.Substring(SrchStrName.Length, EndChr - FirstChr - SrchStrName.Length);
if(ifExist(idList, strId))
{
idList.Add(strId);
NameList.Add(strName);
boxlist.Add(string.Format("{0} = {1}", strId, strName));
}
MainString = MainString.Substring(EndChr + SrchStrIdE.Length);
}
list1.DataSource = null;
list1.DataSource = boxlist;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|