R
R
r4khic2019-08-16 14:13:03
Python
r4khic, 2019-08-16 14:13:03

How to pass a variable (value) to a python function?

Hello ! I have a function that stores this variable in itself. And the linkvariable stores the results of links. And I need to pass the value of the variable to another function
. Here is the function itself:

def get_links(html):
    soup = BeautifulSoup(html, 'lxml')
    links=soup.findAll(link_container_array[0],{link_container_array[1]:link_container_array[2]})
    for link_container in links:
        a_tag = link_container .find("a")
        # Если нашел
        if a_tag:
             link = resource_allnews_link + a_tag.get("href")
    return link

But the function to which you need to pass a variable so that it can receive data with a variablelink
def get_content(html):
     soup = BeautifulSoup(html,'lxml')
     page_url=soup.find(page_link[0],{page_link[1]:page_link[2]})
     print(page_url)

PS Please do not throw stones.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
techkuz, 2019-08-16
@r4khic

def get_content(html, links):
     soup = BeautifulSoup(html,'lxml')
     page_url=soup.find(page_link[0],{page_link[1]:page_link[2]})
     print(page_url)

Call like this:
links = get_links(html)
get_content(html, links)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question