Created
July 29, 2023 14:47
-
-
Save veretennikovalexey/90c810d03a0e150aff633272bca53dc2 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": "ABX9TyNAy4t4YK4WKlYRAJ609HE0", | |
"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/90c810d03a0e150aff633272bca53dc2/untitled6.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"Поступит ли Максим на бюджет ?" | |
], | |
"metadata": { | |
"id": "4Ctv0SbDHWWM" | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"import requests\n", | |
"from bs4 import BeautifulSoup\n", | |
"\n", | |
"url = \"https://pk.mpei.ru/inform/list581bacc.html\"\n", | |
"response = requests.get(url)\n", | |
"if response.status_code == 200:\n", | |
" print(f\"Запрос выполнен успешно (код {response.status_code})\")\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": "6ffdfdb5-cd23-4b1f-ea87-15ccff247f07" | |
}, | |
"execution_count": 1, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Запрос выполнен успешно (код 200)\n", | |
"Приемная комиссия МЭИ. Официальный сайт: Конкурсные списки\n", | |
"<tr class=\"acceptedPoint accepted EduDocOrig\" id=\"p123473\"><td>СНИЛС: 16551058259</td><td>239</td><td>239</td><td>82</td><td>70</td><td>87</td><td>0</td><td>нет</td><td>нет</td><td>да</td><td>нет</td><td>1</td><td>да</td><td>б/о</td><td></td></tr>\n", | |
"acceptedPoint - значит мы в списке: ['acceptedPoint', 'accepted', 'EduDocOrig']\n" | |
] | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment