1

I'm trying to extract some text from a page using Python and Selenium The text is visible to me, but I can't work out how to extract it - I think the text was created in Java.

Im on the URL: "https://sellercentral.amazon.co.uk/hz/fba/profitabilitycalculator/index?lang=en_GB" and have entered the product id 'B00FRJ1R4M' for example, pressed search, then entered '20' in the Amazon Fulfilment Item Price box and pressed calculate.

I'm trying to extract the '-5.59' but to no avail.

enter image description here

The closest I think I've got is the follwing code:

cost = driver.find_element_by_xpath("//*[@id='afn-fees']/dl/dd[15]/input")

print(cost.get_attribute('innerHTML'))
print(driver.execute_script("return arguments[0].innerHTML", cost))

But this for returns 'None'.

Any help would be much appreciated.

1 Answer 1

1

You need to use .get_attribute("value"), since this is an input, and simplify your locator:

cost = driver.find_element_by_css_selector("input.cost-total")
print(cost.get_attribute("value"))

Here input.cost-total CSS selector would match an input element having cost-total class, which is quite readable and reliable locator in this case.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.