last day (17 days later) » 

8:11 PM
Here, is better
 
Sure thing
 
How are you? :p
 
Long time no see, :)
Yeah I'm good can't complain really
yourself?
 
Yea', been busy with work. Nothing to bad...
I need a bit help with a recursion thing
 
You still working EE?
 
8:12 PM
yup
 
Sure no problem, :)
Sweet
 
still working, it's nice here. It's a Belgium company
I have this: dpaste.de/rPne
open the first link :p
 
I'm just finishing a CSGO game, one sec
 
oh, I might want to play some time with you ^_^
long time no play, I used to be quite good at CS
 
I'm average, but I suck, lol
 
8:14 PM
Eh, the idea is to get relaxed and enjoy the game :D It's true, you enjoy it even more when you win
 
Yeah, I always say the same thing, lol
Just not in the mood today, ;(
 
We all have this kind of day ;P
 
Yeah, lol, what's it you want me to look at? :)
 
oh, okay
as you can see there are some categories
7, more precisely
and if you click say, the first one, you get other two categories
and if you click one of the two categories, you'll still get other category
 
Oh, so you want to get all the catigories
 
8:19 PM
Kind of
I want to reach the final category so that I can get the products
and I guess recursion is the way to go, but I'm kind of stuck
:p
 
Fair, I've not done much lxml, so do you mind if I say how I'd do it in like psudo-Python?
 
ofc, I just need the recursion idea
my logic was like this:
 
Just wondering, do you want the data like [[[products], [...]], ...] or [products, ..., ...]
the former can easily be changed to the latter
 
well, it really doesn't matter as long as there's all the data I need. I can work on that after all
Let me tell you how I thought of it
I access the main link
If there are more categories:
go_deeper until there are no more categories
If not, it means we reached the products -> get products_info
 
def read_catigories():
    """Returns catigories, None if there are none."""
    # LXML stuff
    return page.get_catigories()

def read_products():
    """Returns products, None if there are none."""
    # LXML stuff
    return page.get_products()

def read_all_catigories():
    cat = read_catigories()
    if cat is None:
        yield read_products()
    else:
        yield from read_all_catigories()
That should work, roughly.
From that, you'd just need to figure out the lxml
 
8:28 PM
Lemme go throu' it fast
I suppose page is also each function's argument?
 
Yeah that's just some example thing
 
So, something like this? dpaste.de/SRha
maximum recursion depth exceeded while calling a Python object
 
8:46 PM
Kinda, but you should change the cat is None to not cat
 
meh, still, I get RecursionError: maximum recursion depth exceeded while calling a Python object
 
You're gunna have to change page, too, like for page in cat: yield from read_all_catigories(page)
 
which one? tell me in this: dpaste.de/QUDj ^_^
oh, you meant this?
def read_all_categories(page):
    cat = read_categories(page)
    if not cat:
        yield read_products(page)
    else:
        for link in cat:
            yield from read_all_categories(link)
mm, not quite, coz' link in this case is just a str
 
9:17 PM
yea, it beats me
 
@MrGrj Yeah, I think you'll have to read the page then, :/
 
Thanks for the help :D
I'm gonna struggle until it works
 

  last day (17 days later) »