7

I'm placing here HTML code :

<div class="rendering rendering_person rendering_short rendering_person_short">
  <h3 class="title">
    <a rel="Person" href="https://moh-it.pure.elsevier.com/en/persons/massimo-eraldo-abate" class="link person"><span>Massimo Eraldo Abate</span></a>
  </h3>
  <ul class="relations email">
    <li class="email"><a href="[email protected]" class="link"><span>[email protected]</span></a></li>
  </ul>
  <p class="type"><span class="family">Person: </span>Academic</p>
</div>

From above code how to extract Massimo Eraldo Abate?

Please help me.

2 Answers 2

7

You can extract the name using

response.xpath('//h3[@class="title"]/a/span/text()').extract_first()

Also, look at this Scrapinghub's blogpost for introduction to XPath.

Sign up to request clarification or add additional context in comments.

1 Comment

xpath and regex skillz are a must for getting watcha want ... xpath in-depth knowledge will save you so much hastle... look up xpath syntax like preceding-siblings andfollowing-sibbling ... anscestor child nod etc etc... helps a lot with pagination in particular I find
0

Please take a look at this page. there are lots of ways of extracting text scrapy docs

>>> body = '<html><body><span>good</span></body></html>'
>>> Selector(text=body).xpath('//span/text()').extract()

>>> response = HtmlResponse(url='http://example.com', body=body)
>>> Selector(response=response).xpath('//span/text()').extract()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.