As part of a web crawler using scrapy I am trying to press a "show more" button on a webpage to reveal the rest of the page at https://hungryhouse.co.uk/takeaways/aberdeen-bridge-of-dee-ab10 . It looks like a javescript button but I am unable to see how it works.
The code on the web page is:
<div id="restsPages">
<a class="next" data-url="https://hungryhouse.co.uk/takeaways/aberdeen-bridge-of-dee-ab10">Show more</a>
<a class="back">Back to top</a>
</div>
The url within the "data-url" does not reveal more of the page if I just use that as a url.
I am using selenium and the python code i am using to make this work is (and I am new to coding in general but learning fast):
import scrapy
from hungryhouse.items import HungryhouseItem
from selenium import webdriver
class HungryhouseSpider(scrapy.Spider):
name = "hungryhouse"
allowed_domains = ["hungryhouse.co.uk"]
start_urls = ["https://hungryhouse.co.uk/takeaways/westhill-ab10",
]
def __init__(self):
self.driver = webdriver.Chrome()
def parse(self,response):
self.driver.get(response.url)
while True:
next =self.driver.find_element_by_xpath('//*[@id="restsPages"]/a[@class="next"]')
try:
next.click()
except:
break
self.driver.close()
The error i get is: 'chromedriver' executable needs to be in PATH
Any ideas how I can press this button from within the code?