Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use substring() with Import.io?

I'm having some issues with XPath and import.io and I hope you'll be able to help me. :)

The html code:

<a href="page.php?var=12345">

For the moment, I manage to extract the content of the href ( page.php?var=12345 ) with this:

./td[3]/a[1]/@href

Though, I would like to just collect: 12345

substring might be the solution but it does not seem to work on import.io as I use it...

substring(./td[3]/a[1]/@href,13)

Any ideas of what the problem is?

Thank's a lot in advance!

like image 744
Pierre Avatar asked Apr 14 '15 20:04

Pierre


People also ask

What should I import for substring in Java?

substring(int beginIndex, int endIndex) method returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex.

What substring () and substr () will do?

The difference between substring() and substr() The two parameters of substr() are start and length , while for substring() , they are start and end . substr() 's start index will wrap to the end of the string if it is negative, while substring() will clamp it to 0 .

What is the use of substring ()?

The substring() method extracts characters from start to end (exclusive). The substring() method does not change the original string. If start is greater than end, arguments are swapped: (4, 1) = (1, 4). Start or end values less than 0, are treated as 0.

How do you substring a string?

You call the Substring(Int32) method to extract a substring from a string that begins at a specified character position and ends at the end of the string. The starting character position is a zero-based; in other words, the first character in the string is at index 0, not index 1.


1 Answers

Try using this for the xpath: (Have the field selected as Text)

.//*[@class='oeil']/a/@href

Then use this for your regex:

([^=]*)$

This will get you the ISBN number you are looking for.

import.io only support functions in XPath when they return a node list

like image 145
Wilson Hsieh Avatar answered Oct 05 '22 15:10

Wilson Hsieh