-
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;
}
-
December 16th, 2010, 03:15 PM
#2
Re: communicating with facebook problem
-
December 16th, 2010, 07:34 PM
#3
Re: communicating with facebook problem
My first suggestion is that you should use Regular expression for this task, your method isn´t wrong but needs lots of code.
-
December 16th, 2010, 08:53 PM
#4
Re: communicating with facebook problem
If you're going to do something, go about it the right way
http://developers.facebook.com/
www.monotorrent.com For all your .NET bittorrent needs
NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.
-
December 17th, 2010, 03:08 AM
#5
Re: communicating with facebook problem
zeokat, the problem is that not all the users appear in the source code.. so I dunno how to scan the page in order to get more
mutant fruit, that's cheating! im tryna do it in my way
-
December 17th, 2010, 06:22 AM
#6
Re: communicating with facebook problem
Originally Posted by CoNfideNce
mutant fruit, that's cheating! im tryna do it in my way
cheating?! LoooooooL then using .NET is cheating as well, with your mindset you should use the WinAPI directly or still better Assembler because even C would be cheating. you seem to like wasting your time. they made the API to make life easier but you prefer to do it the hard way and reinvent the wheel, whatever, have fun
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
-
December 17th, 2010, 07:58 AM
#7
Re: communicating with facebook problem
Originally Posted by memeloo
cheating?! LoooooooL then using .NET is cheating as well, with your mindset you should use the WinAPI directly or still better Assembler because even C would be cheating. you seem to like wasting your time. they made the API to make life easier but you prefer to do it the hard way and reinvent the wheel, whatever, have fun
if i wanted to practice asm i wouldn't have built that
and that doesn't solve my question yet, please keep it relevant
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
|