Skip to content

Instantly share code, notes, and snippets.

View indrajithi's full-sized avatar
:octocat:
Namaste

Indrajith Indraprastham indrajithi

:octocat:
Namaste
View GitHub Profile
@indrajithi
indrajithi / xpath_soup.py
Created May 28, 2018 19:56 — forked from ergoithz/xpath_soup.py
Generate unique XPATH for BeautifulSoup element
import itertools
def xpath_soup(element):
"""
Generate xpath of soup element
:param element: bs4 text or node
:return: xpath as string
"""
components = []
child = element if element.name else element.parent