File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """(Bypasses the Imperva/Incapsula hCaptcha)"""
2+ from seleniumbase import SB
3+
4+ with SB (uc = True , test = True ) as sb :
5+ url = (
6+ "https://www.gassaferegister.co.uk/gas-safety"
7+ "/gas-safety-certificates-records/building-regulations-certificate"
8+ "/order-replacement-building-regulations-certificate/"
9+ )
10+ sb .activate_cdp_mode (url )
11+ sb .sleep (0.6 )
12+ sb .solve_captcha ()
13+ sb .sleep (1 )
14+ sb .wait_for_element ("#SearchTerm" , timeout = 5 )
15+ sb .sleep (2 )
16+ allow_cookies = 'button:contains("Allow all cookies")'
17+ sb .click_if_visible (allow_cookies , timeout = 2 )
18+ sb .sleep (1.2 )
19+ sb .press_keys ("#SearchTerm" , "Hydrogen" )
20+ sb .sleep (0.5 )
21+ sb .click ("button.search-button" )
22+ sb .sleep (3 )
23+ results = sb .find_elements ("div.search-result" )
24+ for result in results :
25+ print (result .text .replace (" " * 12 , " " ).strip ())
26+ print ()
27+ sb .scroll_to_bottom ()
28+ sb .sleep (1 )
You can’t perform that action at this time.
0 commit comments