Python Forum
[BeautifulSoup] ; comparing attributs with given value
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[BeautifulSoup] ; comparing attributs with given value
#5
Hi

With a lambda expression, it is possible to solve this issue without such oddities as nonlocal or global, nor without introducing in the xml(html) tree the value the tag's arguments are to be compared with.

Example :

# function to search for the tag
def sel_laPage(article, atonique):
	return article.has_attr('α') and atonique >= article['α'] and atonique <= article['ω']

# function to set the value to be compared with the tag's arguments
def contient(atonique):
	return lambda article : sel_laPage(article, atonique)

#function to read the xml file and find the tag into it
def test(fichier, atonique):
	grec=lire_xml(fichier)
	lapage=contient(atonique)
	return grec.find('body').find_all(lapage)
Arbiel
Reply


Messages In This Thread
RE: [BeautifulSoup] ; comparing attributs with given value - by arbiel - Dec-14-2020, 09:45 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020