Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from selenium import webdriver
- from selenium.webdriver.common.keys import Keys
- import time
- from bs4 import BeautifulSoup
- import re
- usr = "*************"
- pwd = "*************"
- fbid = "***startId***"
- FRIEND_DATA = {}
- profile = webdriver.FirefoxProfile("Profiles/test1")
- driver = webdriver.Firefox(firefox_profile=profile)
- def getFriendSource(fbid):
- driver.get("https://www.facebook.com/profile.php?id=%s&sk=friends"% fbid)
- for i in range(5):
- #driver.execute_script("window.scrollTo(0,document.body.scrollHeight)")
- time.sleep(0.1)
- soup = BeautifulSoup(driver.page_source)
- friends = []
- for link in soup.find_all('a'):
- href = str(link.get('data-hovercard'))
- if "hovercard/user.php?id=" in href:
- href = href[28:-59]
- if href not in friends:
- friends.append(href)
- FRIEND_DATA[fbid] = friends
- return friends
- for friend in getFriendSource(fbid):
- getFriendSource(friend)
- driver.close()
- print(FRIEND_DATA)
Advertisement
Add Comment
Please, Sign In to add comment