Accessing website with mechanicalsoup and failing to get table values

32 Views Asked by At

I have some code to login to a website, go to the page I need, then grab the html which should contain a table. However, I'm missing the table's actual values. Clearly doing something wrong, I've never used mechanicalsoup before. D=

I'm using jupyter notebook, python 3.9. Here's my code:

import mechanicalsoup

# Accessing login page
browser = mechanicalsoup.StatefulBrowser()
browser.open("https://myfakewebsite/")
browser.select_form('form[action="/Account/Login?ReturnUrl=%2F"]')

# Logging in
browser["Email"] = "[email protected]"
browser["Password"] = "qwerty123"
browser.submit_selected()

# Moving to page I need after logging in
browser.open("https://myfakewebsite/more")

# Looking at what I've got
browser.page

In a regular browser, this is what I see if I right click and inspect the page:

screenshot

From my code, this is what I see:

<table>
<tr><th align="left" valign="top">Education Facilitator</th><td data-bind="text: PEFContact()" valign="top"></td></tr>
</table>

In other words, the "PEFContact"'s actual email address is not there.

I've tried using browser.page.find_all(), but I still don't get the values. Warning: noob.

0

There are 0 best solutions below