Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://www.facebook.com/search/pages/?q=Los%20Angeles%20remodeling
- https://www.facebook.com/search/pages/?q=Boston%20remodeling
- https://www.facebook.com/search/pages/?q=Chicago%20remodeling
- import time
- from selenium import webdriver
- from bs4 import BeautifulSoup as bs
- import csv
- import requests
- from selenium.webdriver.support.ui import WebDriverWait
- driver = webdriver.Firefox()
- _browser_profile = webdriver.FirefoxProfile()
- _browser_profile.set_preference("dom.webnotifications.enabled", False)
- webdriver.Firefox(firefox_profile=_browser_profile)
- driver.get('https://www.facebook.com')
- username = driver.find_element_by_id("email")
- password = driver.find_element_by_id("pass")
- username.send_keys("robkrouse@gmail.com")
- password.send_keys("Single3#")
- driver.find_element_by_id('loginbutton').click()
- time.sleep(2)
- with open('fb_urls.csv') as f_input, open('fb_profile_urls.csv', 'w', newline='') as f_output:
- csv_input = csv.reader(f_input)
- csv_output = csv.writer(f_output)
- for url in csv_input:
- driver.get(url[0])
- WebDriverWait(driver, 10)
- lenOfPage = driver.execute_script("window.scrollTo(0, document.body.scrollHeight);var lenOfPage=document.body.scrollHeight;return lenOfPage;")
- match=False
- while(match==False):
- lastCount = lenOfPage
- time.sleep(1)
- lenOfPage = driver.execute_script("window.scrollTo(0, document.body.scrollHeight);var lenOfPage=document.body.scrollHeight;return lenOfPage;")
- if lastCount==lenOfPage:
- match=True
- soup = bs(driver.find_elements_by_class_name('_32mo'), "lxml")
- csv_output.writerow(soup)
Add Comment
Please, Sign In to add comment