-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetchBalance.py
36 lines (28 loc) · 2.18 KB
/
fetchBalance.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import requests
from bs4 import BeautifulSoup
def fetchBalance(url, cookie):
# Define the URL of the website you want to fetch
# url = 'https://www.bu.edu/link/bin/uiscgi_studentlink.pl/1675459615?ModuleName=current_balance_meal_and_pt.pl'
# Define the cookie you want to use
# cookie = "f5_cspm=1234; f5avraaaaaaaaaaaaaaaa_session_=HNJFMCMCABAGNNLAIAJKCMOJHCFNCHBJGFGIOPGFLFJNBNPFPJBGGPNIOGFELDJEIJEDEEFEHADHMHLMGMJAANFHHIGEMOJHLJAJIGOEMIBNFAPHPMIGMFOLLEAGIKNM; uiscgi_prod=e8510be2c65c31c1ed824b65ddbf0345:prod; BIGipServerist-uiscgi-app-prod-443-pool=1254475136.47873.0000; BIGipServerwww-prod-crc-443-pool=659366669.47873.0000"
head = {"Cookie": cookie}
# Send a GET request to the website, including the cookie
response = requests.get(url, headers=head)
# Use Beautiful Soup to parse the HTML content of the website
soup = BeautifulSoup(response.text, 'html.parser')
print(soup.text)
# Find all <font> tags with size attribute value of +1 and containing a <b> tag
fonts = soup.find_all('font', attrs={'size': '+1'}, recursive=True)
result = []
# Loop through the fonts and store their text values
for font in fonts:
bold = font.find('b')
if bold:
result.append(bold.text.strip())
return result
if __name__ == '__main__':
url = 'https://www.bu.edu/link/bin/uiscgi_studentlink.pl/1675459615?ModuleName=current_balance_meal_and_pt.pl'
# cookie = "f5_cspm=1234; f5avraaaaaaaaaaaaaaaa_session_=HNJFMCMCABAGNNLAIAJKCMOJHCFNCHBJGFGIOPGFLFJNBNPFPJBGGPNIOGFELDJEIJEDEEFEHADHMHLMGMJAANFHHIGEMOJHLJAJIGOEMIBNFAPHPMIGMFOLLEAGIKNM; uiscgi_prod=e8510be2c65c31c1ed824b65ddbf0345:prod; BIGipServerist-uiscgi-app-prod-443-pool=1254475136.47873.0000; BIGipServerwww-prod-crc-443-pool=659366669.47873.0000"
cookie = "f5_cspm=1234; f5avraaaaaaaaaaaaaaaa_session_=AMKFJCMAABAGNNLAAGEDCMOJHCFNCHBJGFGIOPGFLFJNBNPFPJBGGPNIOGFELDJEIJEDEEFEGMDHPLLMGMJAANFHDLGEINJHLJAJIGOEMIBNFADGPMIGMFOLLEAGIKDC; BIGipServerist-uiscgi-content-prod-443-pool=2315708170.47873.0000; uiscgi_prod=6969c54808a90dff5e353c9e37054afe:prod; BIGipServerist-uiscgi-app-prod-443-pool=1288029568.47873.0000"
mylist = fetchBalance(url, cookie)
print(mylist)