Last active
December 17, 2015 11:49
-
-
Save NikolasTzimoulis/5605089 to your computer and use it in GitHub Desktop.
A scrapper / parser that downloads the list of plus ones (+1's) from a user's public google+ profile. The output is an html file with each link in a separate paragraph.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
profileId = "103814799814962680687" | |
fileName = "C:\\Users\\Nikolas\\Dropbox\\public\\plusones.html" | |
response = urllib2.urlopen('https://plus.google.com/_/plusone/get?oid='+profileId) | |
text = response.read().decode("utf-8") | |
textLines = text.split('\n') | |
linkList = [] | |
for line in textLines: | |
startLink = line.find("[\"http:") + 2 | |
if startLink == 1: continue | |
endLink = line[startLink:].find("\",\"") + startLink | |
startTitle = endLink + 3 | |
endTitle = line[startTitle:].find("\",,\"") + startTitle | |
link = line[startLink:endLink] | |
title = line[startTitle:endTitle] | |
html = "<p><a href=\""+link.decode('unicode-escape')+"\">"+title+"</a></p>" | |
linkList.append(html.encode("utf-8", "replace")) | |
plusonefile = open(fileName, 'w') | |
plusonefile.writelines(linkList) | |
plusonefile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment