title: Using Beautifulsoup and Selenium to get links from a webpage with certain words
body: <p>I wrote this code to log in to my FB account and get all grouplinks on the page using Selenuim and BeautifulSoup but the BeautifulSoup usage isn't working correctly.</p>
  
  <p>I want to know how to use Selenuim and BeautifulSoup in the same code.</p>
  
  <p>I don't want to use the Facebook API; I want to use Selenium and BeautifulSoup.</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  from selenium.webdriver.common.by import By
  import httplib2
  from BeautifulSoup import BeautifulSoup, SoupStrainer
  
  
  usr = raw_input('--&gt; ')
  pwd = raw_input('--&gt; ')
  poo = raw_input('--&gt; ')
  
  driver = webdriver.Firefox()
  # or you can use Chrome(executable_path="/usr/bin/chromedriver")
  driver.get("https://www.facebook.com/groups/?category=membership")
  assert "Facebook" in driver.title
  elem = driver.find_element_by_id("email")
  elem.send_keys(usr)
  elem = driver.find_element_by_id("pass")
  elem.send_keys(pwd)
  elem.send_keys(Keys.RETURN)
  
  scheight = .1
  while scheight &lt; 9.9:
      driver.execute_script("window.scrollTo(0, document.body.scrollHeight/%s);" % scheight)
      scheight += .01
  soup = BeautifulSoup(html)
  http = httplib2.Http()
  status, response = ('https://www.facebook.com/groups/?category=membership')
  
  count = 0
  for link in BeautifulSoup(response, parseOnlyThese=SoupStrainer('a')):
       count = count + 1
  print 'Count: ', count 
  
  for tag in BeautifulSoup(('a')):
      if link.has_key('href'):
          if '/groups/' in link['href']:
  
            print link['href']
  
  
  elem = driver.find_element_by_css_selector(".input.textInput")
  elem.send_keys(poo)
  elem = driver.find_element_by_css_selector(".selected")
  elem.send_keys(Keys.RETURN)
  elem.click()
  time.sleep(5)
  </code></pre>