How to get Href Url links from web url with Python

  python-3.x

I would like to get all the product links for but this one is giving me an error, I don’t know why. Could you help me solve the problem please?

from requests_html import HTMLSession

for page in range(1, 3):
    url = f'https://fr.zalando.be/baskets-homme/adidas-originals__taille-42/?shipped_by_zalando=true&p={page}'

    s = HTMLSession()
    # r = s.get(url, headers=headers, timeout=None, allow_redirects=False)
    r = s.get(url)
    r.html.render(sleep=1)

    products = r.html.xpath(
        '/html/body/div[2]/div/div/x-wrapper-re-1-1/div/div[7]/div/div[2]/div[2]/div[2]',
        first=True)
    # print(products.absolute_links)

    for item in products.absolute_links:
                    # r = s.get(item)
                    print(item)
                    if '/adidas-originals' in products.absolute_links:
                            print(item)
                    else:
                            continue

Source: Python-3x Questions

LEAVE A COMMENT