def getFriendsList(friends, part,s):
ID = vanity
if(part == 1):
index = 0;
elif(part == 2):
index = 24;
elif(part == 3):
index = 24+36
else:
index = 24+36+36
# find scrape their total number of friends
temp = s.get('https://www.facebook.com/' + ID + '/friends')
soup = BeautifulSoup(temp.text,"lxml")
strainer = SoupStrainer('a',href=re.compile("fref=fr_tab"))
# iterator over entire friends list and pull out the relevant information from
# the html docs that display 24 or 36 friends each
while (index < (numFriends)):
if index == 0:
temp = s.get('https://m.facebook.com/' + ID + '/friends')
soup = BeautifulSoup(temp.text,"lxml",parse_only=strainer)
tempLst = soup.findAll('a')
for item in tempLst:
friends.append(item)
index = 24 + 36*3
else:
temp = (s.get('https://m.facebook.com/' + ID + '/friends?startindex='
+ str(index)))
soup = BeautifulSoup(temp.text,"lxml",parse_only=strainer)
tempLst = soup.findAll('a')
for item in tempLst:
friends.append(item)
index = index + 36*4
return
评论列表
文章目录