C
C
ChudoUdo2018-03-04 14:19:57
XPath
ChudoUdo, 2018-03-04 14:19:57

How to select XPath elements without spaces and double quotes?

Selecting an XPath element like this

bank = response.xpath('/html/body/div[2]/div[4]/div[2]/table[2]/tbody/tr[1]/td/text()').extract_first()
,
and in csv I get the following result
"
            BANCO DE COSTA RICA

          "

How to get the same result only without spaces and quotes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
ChudoUdo, 2018-03-04
@ChudoUdo

Found the answer, maybe it will help someone

bank = response.xpath('normalize-space(/html/body/div[2]/div[4]/div[2]/table[2]/tbody/tr[1]/td/text())').extract_first()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question