Skip to content

Instantly share code, notes, and snippets.

@hannesdatta
Created May 11, 2022 09:48
Show Gist options
  • Save hannesdatta/99222e312c734279cee08d14f762ac3e to your computer and use it in GitHub Desktop.
Save hannesdatta/99222e312c734279cee08d14f762ac3e to your computer and use it in GitHub Desktop.
Searching reddit and saving search results with a web scraper
# 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