Exemplo n.º 1
0
# You should only run this script after successfully running mergeRelations.py
import time
from RRBrowser import RenrenBrowser
from RRParser import RenrenParser
from RRRecorder import RenrenRecorder


storePath = 'D:/Projects/NetSci/U&I/data'

rrID = input("Your Renren ID (e.g.239486743): ")
rrUser = input("Your Renren Login Email: ")
rrPassword = input("Your Renren Password: ")

browser = RenrenBrowser(user=rrUser, passwd=rrPassword, path=storePath)
browser.setLogLevel(40)
browser.login()
mergedRec = RenrenRecorder(path=storePath, writeBack=True)
parser = RenrenParser(browser, mergedRec)

cnt = 0
friends = mergedRec.getFriends(rrID)
for rrID in friends:
    cnt += 1
    result = browser.grabProfilePage(rrID)
    print('√ {}: {}/{} {}'.format(rrID, cnt, len(friends), result))
    if result!='skipped':
        time.sleep(10)

parser.profiles()
mergedRec.save()
Exemplo n.º 2
0
from RRParser import RenrenParser

# from rrDB import RenrenDb
from RRRecorder import RenrenRecorder


storePath = "D:/Projects/NetSci/U&I/data"
rrID = input("Your Renren ID (e.g.239486743): ")
rrUser = input("Your Renren Login Email: ")
rrPassword = input("Your Renren Password: ")

# db = RenrenDb()
browser = RenrenBrowser(user=rrUser, passwd=rrPassword, path=storePath)
browser.setLogLevel(40)
browser.login()
recorder = RenrenRecorder(path=browser.getPWDRoot(), writeBack=True)
parser = RenrenParser(browser, recorder)
# print(len(recorder.getFriends(rrID)))

# net1
browser.grabFriendListPages(rrID)
parser.friends()
recorder.save()

# net2
# flist = db.getRenrenId(2, rrID)
myFriends = recorder.getFriends(rrID)
cnt = 0
for rrID in myFriends:
    # loopStart=time.time()
    browser.grabFriendListPages(rrID)
Exemplo n.º 3
0
import os
from RRRecorder import RenrenRecorder


storePath = 'D:/Projects/NetSci/U&I/data'
mergedRec = RenrenRecorder(path=storePath, writeBack=True)

#merge relationship network and names from different centers
for email in os.listdir(storePath):
    localRec = RenrenRecorder(storePath+'/'+email+'/renrenData')
    mergedRec.addRelations(localRec.getRelations())
    mergedRec.addNames(localRec.getNames())

#fix relationship network asymmetry due to that we grab pages at different times
relations = mergedRec.getRelations()
reverse = {}
for rrID1 in relations.keys():
    for rrID2 in relations[rrID1]:
        if rrID2 in reverse:
            reverse[rrID2] = reverse[rrID2] | {rrID1}
        else:
            reverse[rrID2] = {rrID1}
for rrID, friends in reverse.items():
    mergedRec.addFriends(rrID, friends)

mergedRec.save()
Exemplo n.º 4
0
# merge name.p into profile.p
from RRRecorder import RenrenRecorder


storePath = 'D:/Projects/NetSci/U&I/data'
mergedRec = RenrenRecorder(path=storePath, writeBack=True)
profiles = mergedRec.getProfiles()

for rrID, name in mergedRec.getNames().items():
    if rrID in profiles:
        profiles[rrID]['名称'] = name
    else:
        profiles[rrID] = {'名称':name}

mergedRec.save()