The goal of my python code is to find the prices of the land on the webpage, and later on also the land area. The code I currently have outputs .webelement in a list, and I want to change it to text (e.g. $131,000).
Current output:
[]
[<selenium.webdriver.remote.webelement.WebElement (session="51532a6317af2be5bfd34c6406d59028", element="65e6939c-3077-4c7a-8dfa-eaa109a0fc0f")>]
[<selenium.webdriver.remote.webelement.WebElement (session="51532a6317af2be5bfd34c6406d59028", element="0221ed59-744e-4e1e-9fc8-5db77a04a2eb")>]
Below is the current python code I am using:
import requests
url = 'https://www.realestate.com.kh/buy/land/?page=1'
r = requests.get(url)
from bs4 import BeautifulSoup
soup = BeautifulSoup(r.content, 'html.parser')
data= []
price = []
driver = webdriver.Chrome()
driver.get('https://www.realestate.com.kh/buy/land/?page=1')
follow_loop = range(0, 14)
for x in follow_loop:
xpath = '//*[@id="__next"]/main/div[2]/div[1]/div['
xpath += str(x)
xpath += ']/article/div[2]/div[1]/div'
price.append(driver.find_elements_by_xpath(xpath))
for p in price:
print(p)
driver.close()