-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrightmove.py
27 lines (25 loc) · 863 Bytes
/
rightmove.py
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
27
from selenium import webdriver
import time
import re
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
# chrome_options.add_argument("--headless")
# chrome_options.headless = True
driver = webdriver.Chrome(options=chrome_options)
start_url = "https://www.rightmove.co.uk/"
driver.get(start_url)
search_box = driver.find_element_by_xpath("//input[@id='searchLocation']")
search_box.send_keys("SE21 8BD")
driver.find_element_by_xpath("//button[@id='buy']").click()
time.sleep(5)
driver.find_element_by_xpath("//button[@id='submit']").click()
time.sleep(5)
expected_url = driver.current_url
print(expected_url)
pattern = "POSTCODE%(.+?)&"
post_code = re.search(pattern, expected_url)
print(post_code)
post_code = re.findall(r"POSTCODE%(.+?)&", expected_url)
print(post_code)
# print(driver.page_source.encode("utf-8"))
driver.quit()