I want to get address but they provide me empty what I am doing wrong in the XPath..... these is the page link https://www.findtruckservice.com/page/cummins-sales-and-service-farmington-nm-430653
Snapshot of the address:
Code trials:
import scrapy
from scrapy import Selector
from scrapy_selenium import SeleniumRequest
from scrapy.http import Request
class TestSpider(scrapy.Spider):
name = 'test'
def start_requests(self):
yield SeleniumRequest(
url ="https://www.findtruckservice.com/search/?city=Florida%2C+CO&mainCat=1&subCat=Truck+Repair&lat=37.0731&lon=-106.247&cat_field=Mobile+Repair+-+Truck+Repair",
wait_time = 3,
screenshot = True,
callback = self.parse,
dont_filter = True
)
def parse(self, response):
books = response.xpath("//h3//a//@href").extract()
for book in books:
url = response.urljoin(book)
yield Request(url, callback=self.parse_book)
def parse_book(self, response):
address=response.xpath("//div[1][@class='threecol align_left card']//div//text()").get()
yield{
'address':address
}