I'm attempting to utilize Selenium
in order to extract the Javascript
within this specific code snippet:
<div id="imageBlock_feature_div" class="feature" data-feature-name="imageBlock"> <div id="imageBlock" class="a-section imageBlockRearch" aria-hidden="true"> <script type="text/javascript"> P.when('A').register("ImageBlockATF", function(A){ var data = { 'colorImages': { 'initial': [{"hiRes":"https://images-na.ssl-images-amazon.com/images/I/61a%2B2tb6CXL._SL1000_.jpg","thumb":"https://images-na.ssl-images-amazon.com/images/I/41jyDJkFNkL._SX38_SY50_CR,0,0,38,50_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/41jyDJkFNkL.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/61a%2B2t...<more truncated text for brevity> </div> <p>Essentially, utilizing Firebug, I've successfully located the element using the following <code>XPath
:.//*[@id='imageBlock_feature_div']/script
However, when trying to find the element by
XPath
inSelenium
(my coding is done in Java), it results in aNoSuchElementException
.org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":".//*[@id='imageBlock_feature_div']/script"}
The specific product I'm referring to can be found on Amazon's website.
In summary, my goal is to extract all the content from the line that starts with:
<script type="text/javascript">
Is there a method to achieve this extraction from the product page?