communicating with facebook problem
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: communicating with facebook problem

  1. #1
    Join Date
    Nov 2005
    Posts
    17

    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;
    }

  2. #2
    Join Date
    Nov 2005
    Posts
    17

    Re: communicating with facebook problem

    any solutions?

  3. #3
    Join Date
    Oct 2008
    Posts
    30

    Re: communicating with facebook problem

    My first suggestion is that you should use Regular expression for this task, your method isn&#180;t wrong but needs lots of code.

  4. #4
    Join Date
    May 2007
    Posts
    1,546

    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.

  5. #5
    Join Date
    Nov 2005
    Posts
    17

    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

  6. #6
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: communicating with facebook problem

    Quote Originally Posted by CoNfideNce View Post
    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

  7. #7
    Join Date
    Nov 2005
    Posts
    17

    Re: communicating with facebook problem

    Quote Originally Posted by memeloo View Post
    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center