-1

I am use the following xpath selector within the parse method of a scrapy spider

  for item in response.xpath(
         '//div[@id="mosaic-provider-jobcards"]//a//*[boolean(@id)]'
        ):
     print(item.get())

This works and returns the following text for each item extracted

<span title="bla bla bla" id="1211">sdsd</span>

Within in the loop I now want to extract title and id (i.e. bla bla bla and 1211), I attempted the following code but this is not working

  for item in response.xpath(
         '//div[@id="mosaic-provider-jobcards"]//a//*[boolean(@id)]'
        ):
        print(direct_page.xpath(".//title").get())
   

This returning None, I want it to return the title for every span, What am I doing wrong?

SFD
  • 565
  • 7
  • 18
  • I think you have to use @title check https://stackoverflow.com/questions/4531995/getting-attribute-using-xpath – CampingCow Jun 03 '22 at 13:13

1 Answers1

0

use @title

direct_page.xpath('//span/@title').get()
ahmedshahriar
  • 1,053
  • 7
  • 25