Skip to content

Commit 64a2b46

Browse files
committed
Add a Reddit-scraping example
1 parent 37f9ee5 commit 64a2b46

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

examples/cdp_mode/raw_reddit.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Reddit Search / Bypasses reCAPTCHA."""
2+
from seleniumbase import SB
3+
4+
with SB(uc=True, test=True, use_chromium=True) as sb:
5+
search = "reddit+scraper"
6+
url = f"https://www.reddit.com/r/webscraping/search/?q={search}"
7+
sb.activate_cdp_mode(url)
8+
sb.solve_captcha() # Might not be needed
9+
post_title = '[data-testid="post-title"]'
10+
sb.wait_for_element(post_title)
11+
for i in range(8):
12+
sb.scroll_down(25)
13+
sb.sleep(0.2)
14+
posts = sb.select_all(post_title)
15+
print('*** Reddit Posts for "%s":' % search)
16+
for post in posts:
17+
print("* " + post.text)

0 commit comments

Comments
 (0)