| |
teesoft forum Forum for teesoft.info
|
Tip:Click here to scan for System Errors & Optimize PC Performance
| View previous topic :: View next topic |
| Author |
Message |
mrrakura
Joined: 15 Jul 2009 Posts: 6 Location: Germany
|
|
| Back to top |
|
|
|
PageDown
Joined: 09 May 2009 Posts: 777 Location: //div[@class='autopager']
|
Posted: Wed Jul 15, 2009 9:52 pm Post subject: |
|
|
Firstly: this page does have a next page link:
But I will teach you how to do it without a next link anyway. You could still do this if you don't use the next link.
First you have to pick the element that corresponds with the page that you are currently on. On most sites you will notice that the page you are currently on is bold, has a different color, is hightlighted, etc. And most of the times the current/active page will have a different class or element name than the other non active pages.
For exaple: If you click on the selector and you hover over the pagebar you see that (if your're on page 1) that page one has letter b.
And the other pages a.
you select the page 1 and you will get this:
Now you see that Autopager has 5 options for you
You could use the first in the picture (//b) or the second (//div[@id='page_content_inner']/div/div/div/div/div/div/div/div/b)
Why can't you use the others?
| Code:Select All | //div[@id='page_content_inner']/div/div/div/div/div/div/div/div/b[1]
//b[(text()='1')]
//b[contains(text(),'1')] |
Because:
| Code:Select All | | //div[@id='page_content_inner']/div/div/div/div/div/div/div/div/b[1] |
Will always look at the first node because of the '[1]'. This is a fixed position. But the position of the current page is not fixed. When you are in page 1 this link xpath with [1] is the current page. But when you are on page 2, node ...[1] will not be the current page so then it won't work.
| Code:Select All | | //b[(text()='1')] or //b[contains(text(),'1')] |
will look at the element that has the text '1'. But if you are on page 2 the text won't be 1 obviously. So that won't work either.
Therefore you have to pick a more general link xpath. In this case (//b)
Or
| Code:Select All | | //div[@id='page_content_inner']/div/div/div/div/div/div/div/div/b |
which doesn't have a fixed position.
In this case it's wise to use //b as link xpath because it's more general thus more likely to have same link xpath in other section of the site and there aren't any other elements in the page that have the name b. //b will thus only select the current page.
That's the first part of the link xpath. Now you have to tell autopager what position is the next page link.
This is done by adding /following::a[1] or /following-sibling::a[1]
It depends on how the tree is set up. The [1] tell autopager that the next link is the first child in the tree that comes after the b (current page).
Note that 'a' in following::a is not always a. If you hover over the element you will see what the element name is 'a' or 'b' or whatever.
Your link xpath is now
For the content xpath:
Try to select a general content xpath. Best use a content xpath that is rather short and has a logical attribute. Most of the time you will have tags like 'content', 'main conten', 'forumline', 'threadlist' or something like that.
For this site we want to use a content xpath that works for all the other sections. There is artist, albums, selections etc.
So now I click on the selector and try to pick a general content.
I picked this:
div,class: block_heavy block_heavy_violet (see picture)
When you click it Autopager suggest these
You need to choose the content xpath that has one match otherwise it will not work.
You will find 4 contents that have more matches and 3 contents that have one.
However the three contents of which you have to choose are too specific. It most probably will work only on the section you are in. If you go to another section lets say 'collections' the content xpath will not match. A content xpath is needed that also is the same in the other sections. Browse through other section and see if you can find a common conten xpath.
So basically you need to generalize the content by simply leaving only the attribute name. Example:
| Code:Select All | | //div[@class='block_heavy block_heavy_violet' and div[1]/@class='block_heavy_title' and div[2]/@class='block_heavy_content'] |
Too long, too specific:
So use //div[@class='block_heavy block_heavy_violet' ...remove the rest and close with ]
So your content xpath is:
| Code:Select All | | //div[@class='block_heavy block_heavy_violet'] |
Finally:
In the url pattern in the site wizard it says:
| Code:Select All | | http://www.jamendo.com/en/artists* |
This rule will only work for the artists section. You need to generalize this as well by simply only leaving the domain:
Ok. That's it. Hope it's useful. And enjoy Autpager.
Last edited by PageDown on Fri Jul 17, 2009 9:57 am; edited 2 times in total |
|
| Back to top |
|
|
|
mrrakura
Joined: 15 Jul 2009 Posts: 6 Location: Germany
|
Posted: Thu Jul 16, 2009 6:33 pm Post subject: |
|
|
Pocketpride, thank you a lot for your nice tutorial!
With it I might be able to make AP-Settings on my own even though I am really lame at everything that has to do with code.
But I have a question:
How did you choose the "block_heavy block_heavy_violet" as content?
With my mouse I can only chose "block_heavy content" with a pixel-by-pixel search.
I hadn't time to complete your tutorial but i think i can do it tomorrow.
With friendly Greetings
Mr Rakura
|
|
| Back to top |
|
|
|
PageDown
Joined: 09 May 2009 Posts: 777 Location: //div[@class='autopager']
|
Posted: Thu Jul 16, 2009 6:57 pm Post subject: |
|
|
No problem. Glad I could help you.
| Quote: | But I have a question:
How did you choose the "block_heavy block_heavy_violet" as content?
With my mouse I can only chose "block_heavy content" with a pixel-by-pixel search. |
You can widen a selection by using the w key on your keyboard and the n key to narrow a selection. I usually pick a small box and hit the w key a couple of times to widen the selection to see what the selector offers.
BTW: I'm lame with codes too but i'm still learning. I would like learn regular expressions that come handy with some sites.
|
|
| Back to top |
|
|
|
mrrakura
Joined: 15 Jul 2009 Posts: 6 Location: Germany
|
Posted: Fri Jul 17, 2009 8:23 am Post subject: |
|
|
Your tutorial works great.
Thanks for it and the hint with "w" and "n"
I hope in future I can add sites to AutoPager on my own.
I didn't find the AP rule for jamendo in the list so I uploaded it.
I hope it's ok for you. If not I'll try to delete it of course.
With friendly Greetings
Mr Rakura
|
|
| Back to top |
|
|
|
PageDown
Joined: 09 May 2009 Posts: 777 Location: //div[@class='autopager']
|
Posted: Fri Jul 17, 2009 9:45 am Post subject: |
|
|
| Yes thanks for submitting the rule. If you come across problem you can always ask for help
|
|
| Back to top |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|