0

I'm trying to get the value of the vending price of AMZN index market directly from the trading platform plus500, the value changes continuosly so I have to use selenium. The code I'm using is this one:

driver.get("https://app.plus500.com/trade/amazon")
# get AMZN vending price
Sell = driver.find_elements(By.CLASS_NAME, value="sell")
print(Sell)

The html from the source is this:

<div class="sell" data-no-trading="false" id="_win_plus500_bind873" data-show="true">126.28</div>

I need to scrape the value (in this case 126,28) every time it changes. If it is needed I created a dummy Plus500 account for you: username "[email protected]" password: "MyRandomCode87".

2

1 Answer 1

0

To extract the value of the vending price of AMZN index market directly from the trading platform plus500 i.e. the text 126.28 as the element is a dynamic element you need to induce WebDriverWait for the visibility_of_element_located() and you can use either of the following locator strategies:

  • Using XPATH:

    print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//div[starts-with(@class, 'section-table-body')]//span[text()='Amazon']//following::div[2]"))).text)
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    

You can find a relevant discussion in How to retrieve the text of a WebElement using Selenium - Python

Sign up to request clarification or add additional context in comments.

1 Comment

if I have to do it with other data where can I find this code "//div[starts-with(@class, 'section-table-body')]//span[text()='Amazon']//following::div[2]" I tryed to copy the xpath and full xpath but they are not the same as the code you wrote

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.