On this page I need to get information from all tabs(Profile, Reviews, Phone Numbers & Directions).
wellness.py
def profile(self, response):
services = response.xpath('.//span[contains(text(),"Services")]')
education = response.xpath('.//span[contains(text(),"Education")]')
training = response.xpath('.//span[contains(text(),"Training")]')
yield {
'First and Last name': response.css('h1::text').get(),
'About': response.css('.listing-about::text').get(),
'Services': services.xpath('following-sibling::span[1]/text()').extract(),
'Primary Specialty': response.css('.normal::text').get(),
'Address': ' '.join([i.strip() for i in response.css('.office-address span::text').getall()]),
'Practice': response.css('.years-in-service::text').get(),
'Education': education.xpath('following-sibling::span[1]/text()').extract(),
'Training': training.xpath('following-sibling::span[1]/text()').extract(),
'Consumer Feedback': response.css('.item-rating-container a::text').get()
}
Each tab is loading a separate page/url. I think you thought since it was tabbed it was the same page. So you will have to collect the data you want off the first page, request the 2nd page get data, and request the 3rd page. You keep the data from the previous page by passing item in the meta attributes. This is how I would do it. Please note the code for the links is correct you will have to make the selectors for the data points on each page.