-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathraw_gas_records.py
More file actions
26 lines (25 loc) · 948 Bytes
/
raw_gas_records.py
File metadata and controls
26 lines (25 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""(Bypasses the Imperva/Incapsula hCaptcha)"""
from seleniumbase import SB
with SB(uc=True, test=True) as sb:
url = (
"https://www.gassaferegister.co.uk/gas-safety"
"/gas-safety-certificates-records/building-regulations-certificate"
"/order-replacement-building-regulations-certificate/"
)
sb.activate_cdp_mode(url)
sb.sleep(0.6)
sb.solve_captcha()
sb.wait_for_element("#SearchTerm", timeout=5)
sb.sleep(1.4)
allow_cookies = 'button:contains("Allow all cookies")'
sb.click_if_visible(allow_cookies, timeout=3)
sb.sleep(1)
sb.press_keys("#SearchTerm", "Hydrogen")
sb.click_if_visible(allow_cookies, timeout=1)
sb.click("button.search-button")
sb.sleep(3)
results = sb.find_elements("div.search-result")
for result in results:
print(result.text.replace(" " * 12, " ").strip() + "\n")
sb.scroll_to_bottom()
sb.sleep(1)