Targets

Most actions need assign target(s) on pages, the target(s) is(are) DOMs on pages. Targets of human actions("click", "fill", "choice"...) are controls(button, input, select, radio...) on pages; Targets of "capture content" are the contents will be scraped; Targets of "scrape page" can be used for scraping multiple set data. 

 

Target Composition

  1. XPath: FMiner use XPath to locate the contents on pages.
  2. Position: It's an integer value, when there are more than one targets assigned by XPath, it can specify one of them by position. 1 means the first object of the targets. When it's 0, means all targets are assigned.

When recorded an action, program will generate XPath and Position for the targets automatically, but in some special situation and when adjust a project, you need "select target(s)" by yourself.

 

Target selection buttons

Here's some buttons for generating "XPath" and "Postion" to select target(s):  "select target", "change target XPath", "relatively select", "expand", "shrink", "group select".

1. Select Target 

When this button is checked, you can select a target on the page.

 

2. Change selected target

Change selected target(s) XPath. A target can be assigned by many XPath, here are some XPath can be choice for the selected target(s).

  • With(contain, start with) Text ...: Lock the block's XPath using its content, such as, to lock the next page link.
  • With Class ...: When the target has a class attribute, it will show.
  • Short Path: There are some short paths you can try, if FMiner can't locate the target(s) correctly.
  • Full Path: The full path with every DOM's tag names and position in the DOM tree.
  • Normal Path: XPath created by FMiner with some special attributes of the target, such as ID, name...

 

3. Relatively select

Relatively select target on the page from current XPath.

 

4. Expand select

Expand the selected target(s) on page.

 

5. Shrink select

Shrink the selected target(s) on page.

 

6. Group select

This is help you to select multi-block in group. 

 

Skills to select targets correctly

Here are some skills to select targets correctly:

1. Change XPath to "target with(contains, starts with) text"

  • If you want to open a link with fixed text, for example "next", you can change XPath with text xxx.
  • When you want to scrape data contains(starts with) xxx, you can change XPath to contains(starts with) xxx.
 

2. Using "Relatively select"

This is very important and useful feature, for pages like this:

You can select target's label with text xxxx at first, then use Relatively select to select real target beside.

For example, when you want to scrape "Eye color" on this page. You should:

  1. Select "Eye color" on page, then change XPath to with text [Eye color]. The target will locate to label of "Eye color" on page.
  2. Click Relatively select button, then click real color Blue. The target will locate to the real data.

 

3. Try "Short XPath"

The longer the XPath, the greater possibility to wrong. You can select a short XPath to try, if the normal XPath can't work.

 

4. Input XPath manually

You can input XPath manually, if you can't select target correctly with all features of FMiner. Here are some tutorials about XPath:

http://zvon.org/xxl/XPathTutorial/General/examples.html

http://www.w3schools.com/xpath/

And FMiner has a tool of web inspector, when disable record and right click the page select option "Inspect" in the menu, it will show. You can see the page code and DOM tree structure on it. It's helpful to write XPath of targets manually. Here's some useful XPath functions:

text()  // DOM with text, example: //a[text()="next"]
contains()  // example: //a[contains(text(), "next")] , //a[contains(@class, 'page-link')]
starts-with() // example: //a[starts-with(text(),'name:')]

 

See Tutorals "Skills to Select Target Correctly"

 

Other uses of XPath: 

 

How to select a range of targets

How to judge it got last page when loop clicking "next" button or recursively opening "next" link