0

I could not find any method that returns outer html from python playwright page.locator(selector, **kwargs). Am I missing something? locator.inner_html(**kwargs) do exists. However, I am trying to use pandas.read_html and it fails on table locator inner html as it trips table tag.

What I'm currently doing is using bs4 to parse page.content(). something like:

soup = BeautifulSoup(page.content(), 'lxml')
df = pd.read_html(str(soup.select('table.selector')))
hardkoded
  • 18,915
  • 3
  • 52
  • 64
Rahul
  • 10,830
  • 4
  • 53
  • 88

1 Answers1

6

There is no outer_html out of the box. But it's not hard to implement it:

locator.evaluate("el => el.outerHTML") 
hardkoded
  • 18,915
  • 3
  • 52
  • 64