Reputation: 353
I'm using Scrapy to create a crawler.
I want to extract only the title of the links that I will found.
This is the current part of the code that it's important to me:
<a class="cor-produto busca-titulo" title="Melhorar a saúde, economia de tempo e dinheiro: Veja os benefícios do uso da bicicleta" href="//g1.globo.com/busca/click?q=economia&p=0&r=1472008380299&u=http%3A%2F%2Fg1.globo.com%2Fma%2Fmaranhao%2Fjmtv-2edicao%2Fvideos%2Fv%2Fmelhorar-a-saude-economia-de-tempo-e-dinheiro-veja-os-beneficios-do-uso-da-bicicleta%2F5256064%2F&t=informacional&d=false&f=false&ss=8bcd843f636c6982&o=&cat=a">Melhorar a saúde, economia de tempo e dinheiro: Veja os benefíc...</a>
I want to extract only the title and I need to use xpath to do this. Anyone have any suggestion?
Thank you! :)
Upvotes: 1
Views: 88
Reputation: 4021
The XPath would be:
//a/@title
Being sel your Selector instance:
sel.xpath('//a/@title').extract()
Or maybe just from the response object:
response.xpath('//a/@title').extract()
Output:
Melhorar a saúde, economia de tempo e dinheiro: Veja os benefícios do uso da bicicleta
Upvotes: 1