I'm trying to scrape this with a combination of python 3.5/selenium/phantomjs.
There is a button which loads more offers
<button data-behavior="result-paging" class="button button-text--centered">
Mehr laden
</button>
This exact button is twice inside the HTML-Code and if all offers are listed the first button looks as follows, while the second button stays the same:
<button data-behavior="result-paging" class="button button-text--centered is-hidden">
Mehr laden
</button>
To click the first button I tried:
while True:
try:
time.sleep(4)
btnElements = driver.find_elements_by_xpath("//button[@data-behavior='result-paging']")
for btnElement in btnElements:
btnElement.click()
# btnElement.send_keys("\n")
if i==11:
break
else:
i=i+1
except:
break
and
while True:
try:
time.sleep(4)
elements= driver.find_elements_by_xpath("//button[@data-behavior='result-paging']")
driver.execute_script("arguments[0].click();", elements[0])
if i==11:
break
else:
i=i+1
except:
break
The loop was just there for quick testing purposes since the script would run eternally otherwise. With booth approaches no new content was loaded, so clicks werent working.
Does anybody have an idea how to solve this issus (perform clicks and load other offers)?
Edit:
Apparently this problem is caused by phantomjs, since I could run the same script with chromedriver. Unfortunately I need to run phantomjs. Did anybody experienced this behaviour before?