Created
July 18, 2018 03:36
-
-
Save erikgregorywebb/9c809d7107fb3083e333804de831d411 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getListingContent(listing_link): | |
# Open the driver | |
driver = webdriver.Chrome(executable_path="/Users/erikgregorywebb/Downloads/chromedriver 2") | |
driver.get(listing_link) | |
# Collect listing informtion | |
try: | |
title = driver.find_element_by_css_selector('.listingDetails-title') | |
location = driver.find_element_by_css_selector('.listingDetails-location') | |
price = driver.find_element_by_css_selector('.listingDetails-price') | |
views = driver.find_element_by_css_selector('.viewsDesktop-viewsNumber') | |
favorites = driver.find_element_by_css_selector('.viewsDesktop-favoritedNumber') | |
description = driver.find_element_by_css_selector('.listingDescription-text') | |
name = driver.find_element_by_css_selector('.listingContactSeller-firstName-value') | |
# Compile into list | |
listing = [title.text, location.text, price.text, views.text, favorites.text, description.text, name.text, listing_link] | |
driver.close() | |
return listing | |
except: | |
print("An error occured.") | |
driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment