While trying to get information from some web pages using BeautifulSoup, there are many overlapping codes, so I want to make it a function, but I want to call a function within bs
such as find_all
and select
. How can I do it?
import requests
from bs4 import BeautifulSoup
def test(url, function, *lst):
result = requests.get(url)
soup = BeautifulSoup(result.text, "lxml")
result = soup.function(*lst)
return
test('www', find_all)
test('www', select_one)
NameError: name 'find_all' is not defined