Created
July 29, 2023 16:39
-
-
Save veretennikovalexey/ff1be7d993cfa06b3c811854e863da2f to your computer and use it in GitHub Desktop.
untitled6.ipynb
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
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"provenance": [], | |
"authorship_tag": "ABX9TyNArG9/bnvNdu1IdV+l7lzH", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/veretennikovalexey/ff1be7d993cfa06b3c811854e863da2f/untitled6.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"Поступит ли Максим на бюджет ( направление 2 )?" | |
], | |
"metadata": { | |
"id": "4Ctv0SbDHWWM" | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"import requests\n", | |
"from bs4 import BeautifulSoup\n", | |
"\n", | |
"url = \"https://pk.mpei.ru/inform/list14bacc.html\"\n", | |
"response = requests.get(url)\n", | |
"if response.status_code == 200:\n", | |
" print(f\"Запрос выполнен успешно (код {response.status_code}) направление 2\")\n", | |
" soup = BeautifulSoup(response.text, 'html.parser')\n", | |
"\n", | |
" title = soup.title\n", | |
" print(title.text)\n", | |
"\n", | |
" # Поиск всех тегов tr\n", | |
" tr_tags = soup.find_all('tr')\n", | |
"\n", | |
" # Перебираем найденные теги tr\n", | |
" for tr_tag in tr_tags:\n", | |
" # Проверяем наличие атрибута id и его значение\n", | |
" if 'id' in tr_tag.attrs and tr_tag['id'] == 'p123473':\n", | |
" # Выводим на экран тег tr, удовлетворяющий условию\n", | |
" print(tr_tag)\n", | |
"\n", | |
" print(\"acceptedPoint - значит мы в списке:\", tr_tag['class'])" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "kJ8jBkZ0HZi8", | |
"outputId": "fb1563cf-abc9-49fe-b269-4d4339afb6b9" | |
}, | |
"execution_count": 1, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Запрос выполнен успешно (код 200) направление 2\n", | |
"Приемная комиссия МЭИ. Официальный сайт: Конкурсные списки\n" | |
] | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment