Created
November 5, 2020 10:14
-
-
Save devster31/e8960c36099e440f0a652488decdac2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
css = """ | |
table { | |
color: #666; | |
font-family: 'Raleway', sans-serif; | |
font-size: 16px; | |
font-weight: 400; | |
box-sizing: border-box; | |
border-collapse: collapse; | |
border-spacing: 0; | |
line-height: 2; | |
margin-bottom: 40px; | |
width: 100%; | |
} | |
tbody { | |
color: #666; | |
font-family: 'Raleway', sans-serif; | |
font-size: 16px; | |
font-weight: 400; | |
border-collapse: collapse; | |
border-spacing: 0; | |
line-height: 2; | |
box-sizing: border-box; | |
border-bottom: 1px solid #ddd; | |
} | |
tr { | |
color: #666; | |
font-family: 'Raleway', sans-serif; | |
font-size: 16px; | |
font-weight: 400; | |
border-collapse: collapse; | |
border-spacing: 0; | |
line-height: 2; | |
box-sizing: border-box; | |
} | |
td { | |
color: #666; | |
font-family: 'Raleway', sans-serif; | |
font-size: 16px; | |
font-weight: 400; | |
border-collapse: collapse; | |
border-spacing: 0; | |
line-height: 2; | |
width: 105px; | |
box-sizing: border-box; | |
text-align: left; | |
border-top: 1px solid #ddd; | |
padding: 6px 0; | |
} | |
h2 { | |
font-family: 'Raleway', sans-serif; | |
box-sizing: border-box; | |
color: #000; | |
font-weight: 700; | |
line-height: 1.2; | |
margin: 0 0 16px; | |
font-size: 30px; | |
} | |
h3 { | |
font-family: 'Raleway', sans-serif; | |
box-sizing: border-box; | |
color: #000; | |
font-weight: 700; | |
line-height: 1.2; | |
margin: 0 0 16px; | |
font-size: 24px; | |
} | |
p { | |
color: #666; | |
font-family: 'Raleway', sans-serif; | |
font-size: 16px; | |
font-weight: 400; | |
line-height: 1.625; | |
box-sizing: border-box; | |
margin: 0 0 24px; | |
padding: 0; | |
margin-bottom: 26px; | |
} | |
ul { | |
color: #666; | |
font-family: 'Raleway', sans-serif; | |
font-size: 16px; | |
font-weight: 400; | |
line-height: 1.625; | |
box-sizing: border-box; | |
margin: 0; | |
padding: 0; | |
margin-bottom: 26px; | |
margin-left: 40px; | |
} | |
li { | |
color: #666; | |
font-family: 'Raleway', sans-serif; | |
font-size: 16px; | |
font-weight: 400; | |
line-height: 1.625; | |
box-sizing: border-box; | |
list-style-type: disc; | |
} | |
""" | |
page = requests.get("https://www.antibodysociety.org/covid-19-biologics-tracker/") | |
soup = BeautifulSoup(page.content, "lxml") | |
table = soup.find("table") | |
title = table.find_previous_sibling("h2") | |
highlights = table.find_next_siblings(["h3", "p", "ul"]) | |
document = BeautifulSoup("<head><style>{}</style></head>".format(css), features="lxml") | |
document.html.append(title) | |
document.html.append(table) | |
document.html.extend(highlights) | |
res = requests.post( | |
"https://api.mailgun.net/v3/THE_DOMAIN/messages", | |
auth=("api", "THE_API_TOKEN"), | |
data={ | |
"from": '"Grande Capo" <[email protected]>', | |
"to": [ | |
"[email protected]", | |
"[email protected]", | |
], | |
"subject": "testing", | |
"html": document.html.prettify(), | |
}, | |
) | |
print(res, res.text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
beautifulsoup4~=4.9.3 | |
lxml~=4.6.1 | |
requests~=2.24.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment