'BeautifulSoup doesn't show text in class
I have been trying to parse my school's website to make a bot that gets the homework for me. The problem is that BeautifulSoup doesn't show the text I need. On the website it's like this:
<td class="homework">
Paragraph 41, №2,3<br><br>
</td>
But in the result of my code, it shows this:
<td class="homework">
<%= homework %></td>
Why does this happen? Why is there actual text on the website, but some weird replacement in the code? Here is the code I'm using for this:
import requests
from bs4 import BeautifulSoup as bs
url1 = 'https://school.karelia.ru/auth/login'
url2 = 'https://school.karelia.ru/personal-area/#diary'
payload = {
'login_login': 'username',
'login_password': 'password'
}
def getHW():
with requests.session() as s:
s.post(url1, data=payload)
r = s.get(url2)
soup = bs(r.content, 'html.parser')
print(soup.prettify())
getHW()
Solution 1:[1]
The weird <%= homework %> tag is replaced by javascript in the page that presumably gets the homework assignment. Either look through the page source to find where it gets the homework or use selenium, a "browser automator" that actually runs javascript.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alex but school |
