Created
May 11, 2022 09:48
-
-
Save hannesdatta/99222e312c734279cee08d14f762ac3e to your computer and use it in GitHub Desktop.
Searching reddit and saving search results with a web scraper
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
# Setup | |
# Make selenium and chromedriver work for Untappd.com | |
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
from webdriver_manager.chrome import ChromeDriverManager | |
#driver = webdriver.Chrome() | |
driver = webdriver.Chrome(ChromeDriverManager().install()) | |
url = "https://www.reddit.com/search/?q=product%20return" | |
driver.get(url) | |
# loop | |
f=open('reddit_output.csv','a') | |
for item in driver.find_elements_by_class_name('SQnoC3ObvgnGjWt90zD9Z'): | |
f.write(item.text+'\t'+item.get_attribute('href')+'\n') | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment