Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added bot/requirements.txt
Empty file.
36 changes: 36 additions & 0 deletions bot/scraper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from seleniumbase import SB

def getFeaturedShader():
with SB(browser="chrome", headless=False, uc=True) as sb:
# first loads the site and solves the cloudflare captcha
sb.uc_open_with_reconnect(
"https://www.shadertoy.com/",
reconnect_time=3
)

if not sb.is_connected():
sb.reconnect()

sb.uc_gui_handle_captcha()
sb.sleep(10)

# wait for the page to load
sb.wait_for_element(".shaderSmall", timeout=30)

# grabs the first shader on featured shaders and its link
link_element = sb.find_element(
'.shaderSmall a[href^="/view/"]'
)

shader_link = link_element.get_attribute("href")
sb.open(shader_link)

# fetches shader code

sb.wait_for_element(".CodeMirror")

shader_code = sb.execute_script("""
return document.querySelector(".CodeMirror").CodeMirror.getValue();
""")

return shader_link, shader_code
Loading