Skip to content
This repository has been archived by the owner on Mar 2, 2023. It is now read-only.

Commit

Permalink
change pw login, catch when categories not found
Browse files Browse the repository at this point in the history
  • Loading branch information
munyoudoum committed Oct 2, 2020
1 parent 73d390e commit 605745b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fes.events(driver, link="")

- If you use the package's driver, you only needs to login once because it creates selenium folder which will save the Chrome cookies, the settings, extensions, etc, and the logins done in the previous session are present here.
- Example: `facebook_events_scraper.login("myemail@gmail.com", "mypassword")`
i

### event_info(driver, link="")

Expand Down Expand Up @@ -93,6 +94,8 @@ return [
return [events_upcoming(driver, link) + events_recurring(driver, link)]
```

- Note: All the scraping function only works when the facebook layout is the same as when the browser is maximized

## Preview

[![event_info](https://thumbs.gfycat.com/UncommonPoliteIchthyostega-size_restricted.gif)](https://giant.gfycat.com/UncommonPoliteIchthyostega.mp4)
Expand Down
2 changes: 1 addition & 1 deletion facebook_events_scraper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .scraper import events_recurring
from .scraper import events_upcoming
from .scraper import events
__version__ = '0.0.1b2'
__version__ = '0.0.1b3'
4 changes: 2 additions & 2 deletions facebook_events_scraper/login.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
def login(driver, email, password):
def login(driver, email, pw):
driver.get('https://www.facebook.com')
# find the username field and enter the email example@yahoo.com.
username = driver.find_elements_by_css_selector("input[name=email]")
username[0].send_keys(email)
# find the password field and enter the password password.
password = driver.find_elements_by_css_selector("input[name=pass]")
password[0].send_keys(password)
password[0].send_keys(pw)
# find the login button and click it.
loginButton = driver.find_elements_by_css_selector("button[type=submit]")
loginButton[0].click()
6 changes: 4 additions & 2 deletions facebook_events_scraper/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ def event_info(driver, link):
ticket = ticket[0].get_attribute('href')
details_bottom = driver.find_element_by_xpath(
"//*[@id='mount_0_0']/div/div[1]/div[1]/div[3]/div/div/div[1]/div[1]/div[4]/div/div[1]/div/div/div[1]/div[1]/div/div/div/div[last()]")
categories = details_bottom.find_element_by_css_selector(
'div.lhclo0ds').text.split('\n')
categories = details_bottom.find_elements_by_css_selector(
'div.lhclo0ds')
if categories:
categories = categories[0].text.split('\n')
see_more = driver.find_elements_by_xpath(
'//*[@id="mount_0_0"]/div/div[1]/div[1]/div[3]/div/div/div[1]/div[1]/div[4]/div/div[1]/div/div/div[1]/div[1]/div/div/div/div/span/div/div')

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

setuptools.setup(
name="facebook_events_scraper",
version="0.0.1b2",
version="0.0.1b3",
author="munyoudoum",
author_email="munyoudoum@gmail.com",
description="Scrape Facebook page events(recurring and upcoming), and individual event on new Facebook Design",
description="Scrape Facebook page events(recurring and upcoming), and individual event on new Facebook Design using Selenium webdriver",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/munyoudoum/facebook_events_scraper",
Expand Down

0 comments on commit 605745b

Please sign in to comment.