I'm trying to download a few hundred excel files from sellercentral.amazon.de
. As mentioned in my previous post, manual download is not an option, as I need to make several clicks to get to download popup.
In order to do so, I'm using Python and Selenium.
The Problem
However, the website to scrape doesnt simply consist of buttons and links, but custom tags as well. One of these is the tag 'browse-node-component', each of which represents a product (sub-)category. Finding it is no big deal, but the click on it doesn't get executed. The clicks are needed to navigate through the categories to it's children, until a leaf node is reached. The Icon then changes from an arrow to 'select' (see imgur).
The code I've tried so far is:
elements = driver.find_elements_by_tag_name("browse-node-component")
for element in elements:
print("starting")
# Store element name
browse_node = element.find_element_by_class_name("browse-node-text")
browse_node = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, "browse-node-text")))
browse_node_button = element.find_element_by_class_name("a-button-input")
print ("done")
browse_node_button.click()
Exemplary "browse-node-component"-tag
<span>
<div class="a-section a-spacing-none browse-node selected-node" ng-class="(nodeCtrl.node.hasChildren ? 'browse-node' : 'leaf-node') + ' ' + (nodeCtrl.isSelected ? 'selected-node' : '')" ng-click="nodeCtrl.node.hasChildren && nodeCtrl.onBrowseChildren({node:nodeCtrl.node});">
<div class="browse-node-text ng-binding" style="">Auto & Motorrad</div>
<div class="node-icon-btn-block">
<img class="loading-icon ng-hide" src="https://m.media-amazon.com/images/G/01/abis-ui/loading-small._CB192205764_.gif" ng-show="nodeCtrl.isLoading">
<div class="lock-icon ng-hide" ng-show="nodeCtrl.isGated"></div>
<div class="a-icon arrow-right browse-node-arrow" ng-show="nodeCtrl.node.hasChildren"></div>
<div class="select-button-ungated ng-hide" ng-show="!nodeCtrl.isGated && !nodeCtrl.node.hasChildren" ng-click="nodeCtrl.onSelectNode({node:nodeCtrl.node})">
<span class="a-button a-button-base a-button-small select-button"><span class="a-button-inner"><input class="a-button-input" type="submit"><span class="a-button-text" aria-hidden="true">
Auswählen
</span></span></span>
</div>
<div class="gated-button ng-hide" ng-click="nodeCtrl.onRequestApproval({node:nodeCtrl.node})" ng-show="nodeCtrl.isGated && !nodeCtrl.node.hasChildren">
<span class="a-button a-button-primary a-button-small select-button"><span class="a-button-inner"><input class="a-button-input" type="submit"><span class="a-button-text" aria-hidden="true">
Freischaltung beantragen
</span></span></span>
</div>
</div>
</div>
<span>
</span></span></browse-node-component>
The Result
The last output is "done", then the script gets terminated and following message appears:
Message: Element 'input class="a-button-input" type="submit"' could not be scrolled into view
But I am unsure to whether I actually have to press that button. Am I pressing the right one? If so, how can I do it without errors?
I want to navigate through those categories, until i reach a child node and then press the select button of it. Yet I cant show the subcategories of toplevel categories with my code. Please give me a hint on which html-element I have to click on.
See here, for graphical information:
Page when instance is opened with selenium:
Image Source : https://i.stack.imgur.com/Fx3iw.jpg