Skip to content

Instantly share code, notes, and snippets.

@WillKirkmanM
Last active September 21, 2023 11:30
Show Gist options
  • Save WillKirkmanM/c5dbdbb50cff66c39721fee8f37943e3 to your computer and use it in GitHub Desktop.
Save WillKirkmanM/c5dbdbb50cff66c39721fee8f37943e3 to your computer and use it in GitHub Desktop.
List of Chemistry IA's (From https://www.clastify.com/ia/chemistry) | BeautifulSoup Parsing (Saves to File "IA.txt")
import requests
from bs4 import BeautifulSoup
def main():
page = requests.get("https://www.clastify.com/ia/chemistry", headers={'User-Agent': 'Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'})
soup = BeautifulSoup(page.content, 'html.parser')
elements = soup.find_all(class_="MuiTypography-root MuiTypography-subtitle2 css-ydl03f")
file = open("IA.txt", "w", encoding="utf-8")
for element in elements:
file.write(element.text + "\n\n")
file.close()
for element in elements:
print(element.text)
print(f"\nFound: {len(elements)} Chemistry IA's")
print(f"\nFound: {len(elements)} Chemistry IA's")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment