-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnba.py
37 lines (27 loc) · 986 Bytes
/
nba.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
37
import requests
from bs4 import BeautifulSoup
from twilio.rest import Client
from datetime import date
# Returns the current local date
today = date.today().strftime('%B %d, %Y')
# Your Twilio account SID and auth token
account_sid = 'your_account_sid'
auth_token = 'your_auth_token'
# The phone number you want to send the PDF to
to_number = 'phone number you wanna send to'
#Fetch URL
url = "https://official.nba.com/nba-injury-report-2022-23-season/"
# Send a GET request to the URL and store the response
response = requests.get(url)
# Parse the HTML content of the response
soup = BeautifulSoup(response.content, "html.parser")
pdf_link = soup.find("a", string="12:30 a.m ET report").get("href")
client = Client(account_sid, auth_token)
# Send the PDF file as an MMS message
message = client.messages.create(
to=to_number,
media_url=pdf_link,
from_='your twilio phone number here',
body=f"Here is your {today}\'s NBA injury report."
)
print(message.sid)