How can I change the variable lxml?

Viewed 20

im using requests+lxml to parse the urls, im choosing an element by xpath in the loop with different urls, but as a result, the variable gets the value only from the first url. Here is my code.

def parse(url, session):
    r = session.get(url)
    tree = html.fromstring(r.content)
    element = tree.xpath('//*[@id="breadcrumbs"]/li[7]/span/a/text()')
    print(element)
    

session = save_session()
for url in urls:
    parse(url, session)
0 Answers
Related