You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

96 lines
2.7 KiB

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "8bf140f1-5001-4809-a846-d2305968f4a9",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import re\n",
"import requests\n",
"#from dotenv import load_dotenv\n",
"from bs4 import BeautifulSoup\n",
"#from IPython.display import Markdown, display\n",
"#from openai import OpenAI"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9685d1f6-9d65-4be9-8ce8-b769b1a083bd",
"metadata": {},
"outputs": [],
"source": [
"headers = {\n",
" \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36\"\n",
"}\n",
"\n",
"class Website:\n",
"\n",
" def __init__(self, url):\n",
" \"\"\"\n",
" Create this Website object from the given url using the BeautifulSoup library\n",
" \"\"\"\n",
" self.url = url\n",
" response = requests.get(url, headers=headers)\n",
" soup = BeautifulSoup(response.content, 'html.parser')\n",
" self.title = soup.title.string if soup.title else \"No title found\"\n",
" # for irrelevant in soup.body([\"script\", \"style\", \"img\", \"input\"]):\n",
" # irrelevant.decompose()\n",
" self.text = soup.body.get_text(separator=\"\\n\", strip=True)\n",
" self.all = BeautifulSoup(response.content, 'html.parser')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ed42c958-75ee-487e-82d9-893850de8be6",
"metadata": {},
"outputs": [],
"source": [
"url = \"https://www.casestatusext.com/cases/IOE0923829091\"\n",
"website = Website(url)\n",
"text = website.text\n",
"\n",
"result = re.findall(\"(?<=Latest Status\\n)[^\\n]+(?=\\n)\", text)[0]\n",
"normal = \"Case Is Being Actively Reviewed By USCIS\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d47b129c-cbe1-4513-9df4-a37581fabead",
"metadata": {},
"outputs": [],
"source": [
"if(result == normal):\n",
" print(\"No change, but stay hopeful! It won't be much longer.\")\n",
"else:\n",
" print(\"CHECK THE WEBSITE NOW!\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}