Thread Rating:
  • 0 Vote(s) - 0 Average
Help creating "Next Page" function.
Hello guys,

I need implement a "Next Page" function.
The website im scrapping has in some categories multiple pages and only has 24 items per page, so i get the url of the next page.
But now since i have the next page url, how i call the same function to deal with the same data but only on a different page. (Maybe to make my function recursive?)
And how i call the function on the "Next Page" Directory?

Or whats the better aproach to implement a next page functionality, on a multipage website?

Quick brief, lets say:
Im on this page "" and has 24 videos, and the link to the next page where there has more 24, and this goes on about 20 pages.
I grab the link "" on the first page, but how i call the same function to deal with scrapping of the page 2?
And how to implement it on "Next page" directory created by xbmcplugin.addDirectoryItem?

Here's my code at the moment:
def INSIDEcategorie(url):
    addon_handle = int(sys.argv[1])
    r = requests.get(url)
    match = re.compile('<div class="movie-img img-box pseudo-link" data-link="(.+?)">.+?<img src="(.+?)" alt="(.+?)" />',re.DOTALL).findall(r.content)
    next_page = re.compile('<span class="pnext"><a href="(.+?)"><span class="fa fa-angle-double-right"></span></a></span>',re.DOTALL).findall(r.content)
    for url, image, name  in match:
        addDir3(name, url, 3, image, '', '')    
    for next2 in next_page:
        if next2:
            li = xbmcgui.ListItem('Next Page', iconImage='')
            xbmcplugin.addDirectoryItem(handle=addon_handle, url=str(next_page), listitem=li, isFolder=True)

Thanks for the help.
here's a working example:

start with and calculate the next one (
(2017-04-21, 18:57)Skipmode A1 Wrote: here's a working example:

start with and calculate the next one (

I dont need to calculate the next one, i can scrap the link on "", my problem is how to call the same function to scrap the new page.
Thanks for the example.
UPDATE: I've managed to make it work.

Logout Mark Read Team Forum Stats Members Help
Help creating "Next Page" function.00