From db38973a6977b8b4e70e68ebd4b559e27a8af310 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Thu, 4 Oct 2012 20:06:37 +0200 Subject: [PATCH] Modify and add some functions --- webshotslib.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/webshotslib.py b/webshotslib.py index af00ec3..0fd42ca 100644 --- a/webshotslib.py +++ b/webshotslib.py @@ -16,7 +16,18 @@ def get_user_listings(url): return matches -def get_users(url): +def get_users(url, allow_quotes): contents = urllib.urlopen(url).read() - matches = re.findall('http:\/\/community\.webshots\.com\/user\/([^/\'"]+)', contents) - return [value for value in matches if value != "my"] + + if allow_quotes == True: + matches = re.findall('http:\/\/community\.webshots\.com\/user\/([^/]+)', contents) + else: + matches = re.findall('http:\/\/community\.webshots\.com\/user\/([^/\'"]+)', contents) + + count = contents.count("http://community.webshots.com/user/") + + return [value for value in matches if value != "my"], count + +def search_query(query): + query = urllib.quote(query.ljust(3, "%") + "%") + return get_users("http://www.webshots.com/explore/member?action=userSearch&username=%s" % query, True)