|
How to Create AutoPager Rules for new Sites
Detail steps of a real example
The tutorials
You can use AutoPager site work shop to create rules for new sites. Tools->Auto Pager->Site Wizard.
It will auto discovery the 3 most important settings for AutoPager: The site url pattern, the link xpath, the content xpath.
You need to make the url pattern match both your current page and next
pages. The link xpath is used to select the link for next page. The
content xpath is used to select the content you want to add to the page
from next pages.
The autodiscory will get some candidate for you. You can double
click it in the list to see the result. You can also modify it in the
text box, press enter to see the result. please make sure these two
xpath can filter out the right element in current page and the next
pages. You can also find test button in the site work shop toolbar. You
can test it. If it's ok, you can click the "Add Site" button to add the
rules to the setting repository.
There are also pickup link and pickup content buttons. You can use it
to generate new ones base the element you select if there are no xpath
meet the reqiurement. For example, click the clear all button to clear
all the old xpath, then click the pickup link button, mouse your mouse
to find the next page link, press s. AutoPager will try to create some
candidate xpath for the element you select. You can repeat this until
you find the right element to point out the next page link.
If you know xpath well, you can type your own in the text box. The text
box color will show you whether your xpath is validate xpath. Press
enter will select the elements in page which match the xpath.
You can use Tools->Auto Pager->Manage Setting to manage the existing rules. Or to see how other sites are auto paged.
Q & A
Q:
|
I need another quick guide. I've come across a few website I
couldn't get the link path for the next page. Please take a look at teesoft.info
as an example. I would hit the auto discovery button but it comes up
empty and when I click the pickup link button and select page 2, I can
get '//b[contains(text(),'2')]',
but attaching the '/following-sibling::a[1]' doesn't work. In this case
what am I looking for to make this work? Please show me how you do it
so I can do it on my own for other pages like this.
|
A:
Discovery is still not smart enough to cover all sites.
//b[contains(text(),'2')] May not work. Since it points to a certain page.
For these case, I will try do it like finding the navigation bar
(where listed all page links), //div[@id='navbar'] for example. then
find the link or text to the current page, //div[@id='navbar']/b[1] for
example, then //div[@id='navbar']/b[1]/following-sibling::a[1] will be
the one we need.
You can also try use the built in variables, like
//strong/a[contains(%href% , @href)]/following-sibling::a[1]
%href% means the url of the page, //strong/a[contains(%href% ,
@href)] means the link marked as Strong and the link url is same or
included in the page url.
You can also use this to avoid the paging goto a loop. Fox
example, some site they will always have a next link, but it will point
to current page, so you can use an xpath like this
//a[@id='paging_next' and not (contains(%href%,@href))] which will
avoid the links which point to it self.
Give me an example site, I can show you how to do with it.
The full variablelist:
%host% -> document.location.host
%href% -> document.location.href
%hostname% -> document.location.host
%pathname% -> document.location.pathname
%port% -> document.location.port
%protocol% -> document.location.protocol
%search% -> document.location.search
%title% -> document.title
You can find some examples in http://www.teesoft.info/autopager/export/
and http://autopager.mozdev.org/conf.d/autopager.xml
|