Thread: How would I go about reading info from a webpage and sorting it?

  1. #1
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463

    How would I go about reading info from a webpage and sorting it?

    Essentially a list of hiscores for a game.

    I want to get info from the hiscores list and sort it by using my own criteria for searching rather than the default one by the webpage.

    I have no idea how to start off, any tips?

    The webpage is:

    http://hiscore.runescape.com/hiscores.ws

    So as you can see, you can type user names to search or type a rank.

    How can I read this info into a database and then sort it, so I can apply my own search criteria?

    Thanks for any help.

  2. #2
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    There maybe a bit of trouble opening the webpage because they just updated the main website and about 200,000 users are trying to re-update, lol.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Usually just an array will suffice, sorted by score.

    To see if you make the table, compare the score with the lowest score on the table. If it's greater than that, then just find the correct place to insert into the array, then bump all the ones below down one place (and thus losing the former lowest score).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Hi Salem,

    The thing is I know the C details of sorting. But how would I make a connection to a webpage to start reading in the info is the bit that is a mystery to me. Or is there another way to do it?

    CHeers

  5. #5
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Socket programming.

  6. #6
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Oh man..lol

  7. #7
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    I'll help you with it. I want to learn socket programming. Might be fun.

    It is a homework assignment?

  8. #8
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    No it's not a homework assignment lol.

    It's a game. There are members, people who pay. And people who don't pay(me). But the same hiscores list applies to all people.

    Members are usually higher in rank, because they have more stuff to do. I want to sort the hiscores list into finding people who are not members only.

  9. #9
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Have been reading beej's guide to socket programming, it's too complex.

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    libcurl may be a way to go, or wget perhaps?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    I will read up on them, thanks matsp

  12. #12
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    I've been reading beej's guide too. I'm getting it.

  13. #13
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    I didn't understand the implementation of things like AP_INET until I found out they are actually built in c modules, i found that out from other tutorials, i'm going to go over beej's again.

  14. #14
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    libwww comes with a built in HTML/XML parser. But I'd suggest libcurl with something like libxml (or just parse the page yourself).

  15. #15
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Can you explain that in a bit more depth? ^^

    I downloaded libcurl, but I only got the source code, I have no idea how to compile so many different files.

Popular pages Recent additions subscribe to a feed