?

Log in

No account? Create an account
I've noticed that some apps can retrieve friend lists without a… - LiveJournal Client Discussions [entries|archive|friends|userinfo]
LiveJournal Client Discussions

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

[Dec. 6th, 2003|05:01 pm]
LiveJournal Client Discussions

lj_clients

[stubbs]
I've noticed that some apps can retrieve friend lists without a password, despite the fact that the protocol says that one is required for getfriends. Anyone know how this is accomplished?
linkReply

Comments:
[User Picture]From: stubbs
2003-12-06 02:15 pm (UTC)
e.g. http://ljmaps.robobeasts.com/

In fact, that one seems to do a lot of stuff without passwords.

(Reply) (Thread)
[User Picture]From: stubbs
2003-12-06 02:22 pm (UTC)
(Reply) (Parent) (Thread)
[User Picture]From: stubbs
2003-12-06 02:25 pm (UTC)
(Reply) (Parent) (Thread)
[User Picture]From: kumokasumi
2003-12-06 02:22 pm (UTC)
Screen-scraping the website, probably...
(Reply) (Thread)
[User Picture]From: stubbs
2003-12-06 02:26 pm (UTC)
I doubt it; everyone and their brother appears to be doing it, whereas parsing an entire webpage is fairly tedious.
(Reply) (Parent) (Thread)
[User Picture]From: vulture23
2003-12-06 03:18 pm (UTC)
It's not all that horrendously tedious. You simply scan for the "friends" link, then grab all of the links after that until you hit "friends of". Provided that you're using a halfway decent HTML parser, this wouldn't be terribly painful.
(Reply) (Parent) (Thread)
[User Picture]From: mcfnord
2003-12-06 03:51 pm (UTC)
but the payoff is there.

i think it'd be cool for people seeking friends data to cooperate to widen the reach and lessen the burden on lj servers.
(Reply) (Parent) (Thread)
[User Picture]From: charles
2003-12-06 06:12 pm (UTC)

It's easy.

I hacked this together in Java once. I have a Ruby version that's shorter, but I cant' find it right now. Standard disclaimers apply: really dodgy code, etc.

    /**
     * Scrape the list of friends usernames from a standard livejournal friends
     * page. Communities are considered to have no friends.
     * 
     * @param userInfoPage the complete text of the user's userinfo page.
     * @return List a list of names of that user's friends. May be empty, but
     * will never be null.
     */
    private List extractFriendsList(String userInfoPage) {
        List friends = new ArrayList();
        int findex = userInfoPage.indexOf("Friends</a>:");
        if (findex != -1) {
            userInfoPage = userInfoPage.substring(findex);
            userInfoPage =
                userInfoPage.substring(0, userInfoPage.indexOf("</tr>"));
            int i;
            while ((i = userInfoPage.indexOf("user=")) != -1) {
                userInfoPage = userInfoPage.substring(i + 5);
                userInfoPage = readNextUser(userInfoPage, friends);
            }
        }
        return friends;
    }

    /**
     * Given a string extract from the userinfo page that starts with a
     * username, add that username to the supplied list, and return the string
     * starting at the end of the username, so that the scraper can find the
     * next one.
     * 
     * @param s the extract from the userinfo page, first character being the
     * start of a friend's username
     * @param friends the list to append the username to
     * @return String the remainder of the string after the username was
     * extracted.
     */
    private String readNextUser(String s, List friends) {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '"' || s.charAt(i) == '\'') {
                friends.add(buf.toString());
                return s.substring(i);
            }

            buf.append(s.charAt(i));
        }

        throw new IllegalStateException("Damnit");
    }
(Reply) (Parent) (Thread)
From: jdlinx
2003-12-06 03:56 pm (UTC)
I wouldn't use that method. It would be a killer on bandwidth.
(Reply) (Parent) (Thread)
[User Picture]From: adrieljohnson
2003-12-06 02:50 pm (UTC)
This is done by parsing the web page http://www.livejournal.com/userinfo.bml?user=example
(Reply) (Thread)
From: jdlinx
2003-12-06 03:53 pm (UTC)
According to my memory some of those sites use a diffrent interface reserved for them. http://www.petekrawczyk.com/lj_connect/ uses one of those interfaces. Others might just do a screen scrape.
(Reply) (Thread)
[User Picture]From: quirrc
2003-12-07 12:45 am (UTC)
parsing directorysearch
(Reply) (Thread)