Skip to content

Instantly share code, notes, and snippets.

@ischurov
Created Apr 19, 2022
Embed
What would you like to do?
Lesson22
{
"cells": [
{
"metadata": {
"scrolled": true,
"trusted": false
},
"id": "reverse-webcam",
"cell_type": "code",
"source": "%pip install --upgrade selenium",
"execution_count": 1,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "Requirement already satisfied: selenium in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (4.1.3)\nRequirement already satisfied: urllib3[secure,socks]~=1.26 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from selenium) (1.26.9)\nRequirement already satisfied: trio-websocket~=0.9 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from selenium) (0.9.2)\nRequirement already satisfied: trio~=0.17 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from selenium) (0.20.0)\nRequirement already satisfied: sortedcontainers in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from trio~=0.17->selenium) (2.2.2)\nRequirement already satisfied: sniffio in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from trio~=0.17->selenium) (1.2.0)\nRequirement already satisfied: attrs>=19.2.0 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from trio~=0.17->selenium) (20.3.0)\nRequirement already satisfied: async-generator>=1.9 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from trio~=0.17->selenium) (1.10)\nRequirement already satisfied: outcome in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from trio~=0.17->selenium) (1.1.0)\nRequirement already satisfied: idna in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from trio~=0.17->selenium) (2.10)\nRequirement already satisfied: wsproto>=0.14 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from trio-websocket~=0.9->selenium) (1.1.0)\nRequirement already satisfied: PySocks!=1.5.7,<2.0,>=1.5.6 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from urllib3[secure,socks]~=1.26->selenium) (1.7.1)\nRequirement already satisfied: cryptography>=1.3.4 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from urllib3[secure,socks]~=1.26->selenium) (36.0.2)\nRequirement already satisfied: pyOpenSSL>=0.14 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from urllib3[secure,socks]~=1.26->selenium) (22.0.0)\nRequirement already satisfied: certifi in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from urllib3[secure,socks]~=1.26->selenium) (2021.10.8)\nRequirement already satisfied: cffi>=1.12 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from cryptography>=1.3.4->urllib3[secure,socks]~=1.26->selenium) (1.14.4)\nRequirement already satisfied: h11<1,>=0.9.0 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from wsproto>=0.14->trio-websocket~=0.9->selenium) (0.13.0)\nRequirement already satisfied: pycparser in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from cffi>=1.12->cryptography>=1.3.4->urllib3[secure,socks]~=1.26->selenium) (2.20)\nNote: you may need to restart the kernel to use updated packages.\n"
}
]
},
{
"metadata": {
"scrolled": true,
"trusted": false
},
"id": "substantial-usage",
"cell_type": "code",
"source": "%pip install --upgrade webdriver_manager",
"execution_count": 2,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "Requirement already satisfied: webdriver_manager in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (3.5.4)\nRequirement already satisfied: requests in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from webdriver_manager) (2.27.1)\nRequirement already satisfied: idna<4,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from requests->webdriver_manager) (2.10)\nRequirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from requests->webdriver_manager) (2021.10.8)\nRequirement already satisfied: charset-normalizer~=2.0.0 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from requests->webdriver_manager) (2.0.12)\nRequirement already satisfied: urllib3<1.27,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from requests->webdriver_manager) (1.26.9)\nNote: you may need to restart the kernel to use updated packages.\n"
}
]
},
{
"metadata": {
"trusted": false
},
"id": "attempted-taylor",
"cell_type": "code",
"source": "from selenium import webdriver\nfrom selenium.webdriver.chrome.service import Service\nfrom webdriver_manager.chrome import ChromeDriverManager\n\ndriver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))\ndriver.get(\"https://www.google.com\")",
"execution_count": 39,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": "\n\n====== WebDriver manager ======\nCurrent google-chrome version is 100.0.4896\nGet LATEST chromedriver version for 100.0.4896 google-chrome\nDriver [/Users/user/.wdm/drivers/chromedriver/mac64/100.0.4896.60/chromedriver] found in cache\n"
}
]
},
{
"metadata": {
"trusted": false
},
"id": "prepared-finish",
"cell_type": "code",
"source": "driver.get(\"https://hse.ru/\")",
"execution_count": 4,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "pursuant-education",
"cell_type": "code",
"source": "from selenium.webdriver.common.by import By",
"execution_count": 5,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "dried-failure",
"cell_type": "code",
"source": "driver.find_element_by_css_selector(\"h3.post__title\")",
"execution_count": 7,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": "<ipython-input-7-7dff57de231b>:1: DeprecationWarning: find_element_by_css_selector is deprecated. Please use find_element(by=By.CSS_SELECTOR, value=css_selector) instead\n driver.find_element_by_css_selector(\"h3.post__title\")\n"
},
{
"data": {
"text/plain": "<selenium.webdriver.remote.webelement.WebElement (session=\"9c4682299325fa9656ed876987445270\", element=\"6afd9961-b1ef-4d4a-b5a5-a14e865db343\")>"
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"trusted": false
},
"id": "fancy-colonial",
"cell_type": "code",
"source": "h3 = driver.find_elements(By.CSS_SELECTOR, \"h3.post__title\")[2]",
"execution_count": 8,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "affected-advocate",
"cell_type": "code",
"source": "h3.get_attribute(\"innerHTML\")",
"execution_count": 9,
"outputs": [
{
"data": {
"text/plain": "'<a href=\"https://www.hse.ru/news/expertise/589514691.html\">Интеграция и торговля в ЕАЭС: ситуация стабильная, но требуется более активная политика</a>'"
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"trusted": false
},
"id": "possible-contribution",
"cell_type": "code",
"source": "h3.find_element(By.TAG_NAME, \"a\").get_attribute(\"href\")",
"execution_count": 11,
"outputs": [
{
"data": {
"text/plain": "'https://www.hse.ru/news/expertise/589514691.html'"
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"trusted": false
},
"id": "comprehensive-master",
"cell_type": "code",
"source": "h3.find_element(By.TAG_NAME, \"a\").get_attribute(\"innerHTML\")",
"execution_count": 14,
"outputs": [
{
"ename": "StaleElementReferenceException",
"evalue": "Message: stale element reference: element is not attached to the page document\n (Session info: chrome=100.0.4896.88)\nStacktrace:\n0 chromedriver 0x00000001046413d9 chromedriver + 5104601\n1 chromedriver 0x00000001045d1bf3 chromedriver + 4647923\n2 chromedriver 0x00000001041c2b48 chromedriver + 392008\n3 chromedriver 0x00000001041c5a87 chromedriver + 404103\n4 chromedriver 0x00000001041c5926 chromedriver + 403750\n5 chromedriver 0x00000001041c5bec chromedriver + 404460\n6 chromedriver 0x00000001041f7b44 chromedriver + 609092\n7 chromedriver 0x00000001041f7fe1 chromedriver + 610273\n8 chromedriver 0x00000001041ec6f7 chromedriver + 562935\n9 chromedriver 0x00000001042156ed chromedriver + 730861\n10 chromedriver 0x00000001041ec635 chromedriver + 562741\n11 chromedriver 0x00000001042157ce chromedriver + 731086\n12 chromedriver 0x0000000104228091 chromedriver + 807057\n13 chromedriver 0x00000001042155b3 chromedriver + 730547\n14 chromedriver 0x00000001041eb139 chromedriver + 557369\n15 chromedriver 0x00000001041ec165 chromedriver + 561509\n16 chromedriver 0x000000010460039d chromedriver + 4838301\n17 chromedriver 0x0000000104618cde chromedriver + 4938974\n18 chromedriver 0x000000010461db5e chromedriver + 4959070\n19 chromedriver 0x000000010461994a chromedriver + 4942154\n20 chromedriver 0x00000001045f533c chromedriver + 4793148\n21 chromedriver 0x00000001046333b8 chromedriver + 5047224\n22 chromedriver 0x000000010463353f chromedriver + 5047615\n23 chromedriver 0x0000000104648705 chromedriver + 5134085\n24 libsystem_pthread.dylib 0x00007ff8139f54e1 _pthread_start + 125\n25 libsystem_pthread.dylib 0x00007ff8139f0f6b thread_start + 15\n",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mStaleElementReferenceException\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-14-6951423c1e70>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mh3\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfind_element\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mBy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mTAG_NAME\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"a\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_attribute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"text\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py\u001b[0m in \u001b[0;36mfind_element\u001b[0;34m(self, by, value)\u001b[0m\n\u001b[1;32m 733\u001b[0m \u001b[0mvalue\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'[name=\"%s\"]'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 734\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 735\u001b[0;31m return self._execute(Command.FIND_CHILD_ELEMENT,\n\u001b[0m\u001b[1;32m 736\u001b[0m {\"using\": by, \"value\": value})['value']\n\u001b[1;32m 737\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py\u001b[0m in \u001b[0;36m_execute\u001b[0;34m(self, command, params)\u001b[0m\n\u001b[1;32m 708\u001b[0m \u001b[0mparams\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 709\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'id'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_id\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 710\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parent\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexecute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcommand\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 711\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 712\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mfind_element\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mby\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mBy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mID\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py\u001b[0m in \u001b[0;36mexecute\u001b[0;34m(self, driver_command, params)\u001b[0m\n\u001b[1;32m 423\u001b[0m \u001b[0mresponse\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcommand_executor\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexecute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdriver_command\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 424\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mresponse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 425\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0merror_handler\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcheck_response\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresponse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 426\u001b[0m response['value'] = self._unwrap_value(\n\u001b[1;32m 427\u001b[0m response.get('value', None))\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py\u001b[0m in \u001b[0;36mcheck_response\u001b[0;34m(self, response)\u001b[0m\n\u001b[1;32m 245\u001b[0m \u001b[0malert_text\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'alert'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'text'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 246\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mexception_class\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmessage\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mscreen\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstacktrace\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0malert_text\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# type: ignore[call-arg] # mypy is not smart enough here\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 247\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mexception_class\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmessage\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mscreen\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstacktrace\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 248\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 249\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_value_or_default\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mobj\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mMapping\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0m_KT\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0m_VT\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0m_KT\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdefault\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0m_VT\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m->\u001b[0m \u001b[0m_VT\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mStaleElementReferenceException\u001b[0m: Message: stale element reference: element is not attached to the page document\n (Session info: chrome=100.0.4896.88)\nStacktrace:\n0 chromedriver 0x00000001046413d9 chromedriver + 5104601\n1 chromedriver 0x00000001045d1bf3 chromedriver + 4647923\n2 chromedriver 0x00000001041c2b48 chromedriver + 392008\n3 chromedriver 0x00000001041c5a87 chromedriver + 404103\n4 chromedriver 0x00000001041c5926 chromedriver + 403750\n5 chromedriver 0x00000001041c5bec chromedriver + 404460\n6 chromedriver 0x00000001041f7b44 chromedriver + 609092\n7 chromedriver 0x00000001041f7fe1 chromedriver + 610273\n8 chromedriver 0x00000001041ec6f7 chromedriver + 562935\n9 chromedriver 0x00000001042156ed chromedriver + 730861\n10 chromedriver 0x00000001041ec635 chromedriver + 562741\n11 chromedriver 0x00000001042157ce chromedriver + 731086\n12 chromedriver 0x0000000104228091 chromedriver + 807057\n13 chromedriver 0x00000001042155b3 chromedriver + 730547\n14 chromedriver 0x00000001041eb139 chromedriver + 557369\n15 chromedriver 0x00000001041ec165 chromedriver + 561509\n16 chromedriver 0x000000010460039d chromedriver + 4838301\n17 chromedriver 0x0000000104618cde chromedriver + 4938974\n18 chromedriver 0x000000010461db5e chromedriver + 4959070\n19 chromedriver 0x000000010461994a chromedriver + 4942154\n20 chromedriver 0x00000001045f533c chromedriver + 4793148\n21 chromedriver 0x00000001046333b8 chromedriver + 5047224\n22 chromedriver 0x000000010463353f chromedriver + 5047615\n23 chromedriver 0x0000000104648705 chromedriver + 5134085\n24 libsystem_pthread.dylib 0x00007ff8139f54e1 _pthread_start + 125\n25 libsystem_pthread.dylib 0x00007ff8139f0f6b thread_start + 15\n"
]
}
]
},
{
"metadata": {
"trusted": false
},
"id": "personal-desperate",
"cell_type": "code",
"source": "h3.find_element(By.TAG_NAME, \"a\").click()",
"execution_count": 13,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "greenhouse-bicycle",
"cell_type": "code",
"source": "url = \"https://www.okeydostavka.ru/msk/molochnye-produkty-syry-iaitso/molochnye-produkty/moloko-i-slivki\"\ndriver.get(url)",
"execution_count": 40,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "governing-aruba",
"cell_type": "code",
"source": "products = driver.find_elements(By.CSS_SELECTOR, \n \"div.product\")",
"execution_count": 41,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "heavy-principle",
"cell_type": "code",
"source": "product = products[0]",
"execution_count": 42,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "silver-friend",
"cell_type": "code",
"source": "name = product.find_element(By.CSS_SELECTOR, \"div.product-name\").text",
"execution_count": 43,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "unlikely-central",
"cell_type": "code",
"source": "span_price = product.find_element(By.CSS_SELECTOR, \"span.price\")\nprice = span_price.get_attribute(\"innerHTML\").strip()\nred_label = 'label-red' in span_price.get_attribute(\"class\")",
"execution_count": 46,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "common-exclusive",
"cell_type": "code",
"source": "rows = []\nfor product in products:\n name = product.find_element(By.CSS_SELECTOR, \"div.product-name\").text\n span_price = product.find_element(By.CSS_SELECTOR, \"span.price\")\n price = span_price.get_attribute(\"innerHTML\").strip()\n red_label = 'label-red' in span_price.get_attribute(\"class\")\n rows.append([name, price, red_label])",
"execution_count": 47,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "forty-cartridge",
"cell_type": "code",
"source": "rows",
"execution_count": 48,
"outputs": [
{
"data": {
"text/plain": "[['БЗМЖ Молоко паст Домик в деревне ДерОтб 3,5-4,5% ...', '84,99 ₽', True],\n ['БЗМЖ Коктейль утп Чудо шоколад 3% 200мл', '54,99 ₽', False],\n ['БЗМЖ Сливки УТП питевые Campina 10% 10*17г', '88,99 ₽', False],\n ['БЗМЖ Сливки President взбитые 20% 250г', '384,00 ₽', False],\n ['БЗМЖ Сливки Альпенгурт порционные 10% 10*10г', '44,99 ₽', False],\n ['БЗМЖ Сливки УТП питевые Campina 10% 10*10г', '54,99 ₽', False],\n ['БЗМЖ Сливки Петмол питьевые утп 11% 500г', '179,99 ₽', False],\n ['БЗМЖ Молоко утп М 3,2% 950г тва', '98,99 ₽', False],\n ['БЗМЖ Молоко утп Valio 1,5% 1кг', '129,99 ₽', False],\n ['БЗМЖ Молоко утп Valio 3,2% 1кг', '141,99 ₽', False],\n ['БЗМЖ Молоко утп Valio 2,5% 1кг', '155,99 ₽', False],\n ['БЗМЖ Сливки д/кофе Valio 10% 250мл', '92,99 ₽', False],\n ['БЗМЖ Молоко утп Большая кружка 2,5% 1980г', '199,99 ₽', False],\n ['БЗМЖ Молоко утп Большая кружка 3,2% 1980г', '209,00 ₽', False],\n ['БЗМЖ Молоко утп Parmalat 3,5% 1л', '77,99 ₽', True],\n ['БЗМЖ Молоко утп Parmalat 0,5% 1л', '89,99 ₽', False],\n ['БЗМЖ Сливки Parmalat стер кулинарные23%500г', '189,99 ₽', False],\n ['БЗМЖ Сливки Белый город стерилизованные 10% 200г', '46,99 ₽', False],\n ['БЗМЖ Сливки стерил Белый город 33%, 500г', '239,00 ₽', False],\n ['БЗМЖ Молоко пастер Вкуснотеево цельное 3,5-6% 900г ...', '94,49 ₽', False],\n ['БЗМЖ Молоко пастеризованное Рузское 3,2-4,0% 1кг ...', '149,99 ₽', False],\n ['БЗМЖ Молоко пастер Простоквашино отб 3,4-4,5% 930мл ...', '79,99 ₽', True],\n ['БЗМЖ Коктейль утп Parmalat сaffe latte 2,3% 0,5л', '70,99 ₽', False],\n ['БЗМЖ Сливки утп Parmalat 11% 500г', '128,99 ₽', False],\n ['БЗМЖ Молоко пастер Веселый Мол отб 3,5-4,5% 930мл ...', '104,49 ₽', False],\n ['БЗМЖ Молоко утп Parmalat Dietalat 0,5% 1л', '102,49 ₽', False],\n ['БЗМЖ Сливки утп Parmalat 35% 500г', '254,00 ₽', False],\n ['БЗМЖ Коктейль утп Parmalat капучино 1,5%, 0,5л', '70,99 ₽', False],\n ['БЗМЖ Молоко утп Белый город 1,5% 1л', '82,49 ₽', False],\n ['БЗМЖ Коктейль утп Белый город клубника 1,5% 500г', '60,49 ₽', False],\n ['БЗМЖ Молоко утп Простоквашино 3,2% 950г тва', '119,99 ₽', False],\n ['БЗМЖ Коктейль утп Чудо ваниль 2% 200мл', '54,99 ₽', False],\n ['БЗМЖ Молоко пастер Домик в деревне 2,5% 930мл пэт', '79,99 ₽', False],\n ['БЗМЖ Молоко пастер топленое Простоквашино 3,2% ...', '99,99 ₽', False],\n ['БЗМЖ Молоко утп Белый город 2,5% 1кг', '86,49 ₽', False],\n ['БЗМЖ Молоко утп Parmalat 3,5% 200мл', '33,99 ₽', False],\n ['БЗМЖ Молоко утп Домик в деревне 3,2% 925мл тба', '116,99 ₽', False],\n ['БЗМЖ Коктейль утп Чудо клубника 2% 200мл', '54,99 ₽', False],\n ['БЗМЖ Коктейль утп Чудо шоколад 2% 960г тва', '164,49 ₽', False],\n ['БЗМЖ Сливки Домик в деревне стерилизованные 20% ...', '114,99 ₽', False],\n ['БЗМЖ Сливки Домик в деревне стерилизованные 10% ...', '124,99 ₽', True],\n ['БЗМЖ Сливки Домик в деревне стер 10% 200г пак', '78,49 ₽', False],\n ['БЗМЖ Сливки Простоквашино увт-обр стер10% 200г', '81,99 ₽', False],\n ['БЗМЖ Молоко утп Простоквашино 2,5% 950мл тва', '116,99 ₽', False],\n ['БЗМЖ Сливки Простоквашино стерилизованные 10% 350г', '119,99 ₽', False],\n ['БЗМЖ Сливки Простоквашино стерилизованные 20% 350г', '182,99 ₽', False],\n ['БЗМЖ Молоко утп Parmalat 1,8% 200мл', '33,49 ₽', False],\n ['БЗМЖ Молоко паст Домик в деревне ДерОтб ...', '169,49 ₽', False],\n ['БЗМЖ Молоко пастер Домик в деревне 2,5% 1400мл пэт', '153,99 ₽', False],\n ['БЗМЖ Молоко утп Valio 0% 1кг', '118,99 ₽', False],\n ['БЗМЖ Молоко паст Киржачский МЗ отб 3,4-6% 930г пэт', '99,99 ₽', False],\n ['БЗМЖ Молоко ТЧН! утп 2,5% 1л TBA', '76,49 ₽', False],\n ['БЗМЖ Молоко утп ОКЕЙ Daily 1,5% 1л тва', '50,99 ₽', False],\n ['БЗМЖ Сливки Домик в деревне стерилизованные 33% ...', '224,99 ₽', True],\n ['БЗМЖ Молоко пастер Правильное молоко 3,2-4,0% 2л ...', '188,99 ₽', False],\n ['БЗМЖ Молоко пастер Правильное молоко 2,5% 0,9л пэт', '99,99 ₽', False],\n ['БЗМЖ Молоко утп Домик в деревне 2,5% 950г', '89,99 ₽', True],\n ['БЗМЖ Молоко утп Домик в деревне 3,5% 950г', '114,99 ₽', False],\n ['БЗМЖ Молоко утп Домик в деревне 0,5% 950г тба', '95,49 ₽', False],\n ['БЗМЖ Молоко утп Домик в деревне 6% 950г тва', '167,99 ₽', False],\n ['БЗМЖ Молоко утп Домик в деревне 1,5% 950г', '104,99 ₽', False],\n ['БЗМЖ Сливки Домик в деревне стерилизованные 10% ...', '198,99 ₽', False],\n ['БЗМЖ Коктейль молочный Чудо шоколад 3% 950г пэт', '162,49 ₽', False],\n ['БЗМЖ Сливки питьевые утп Петмол 22% 500г', '264,00 ₽', False],\n ['БЗМЖ Сливки Петмол крем сливочный 33% 500г', '309,00 ₽', False],\n ['БЗМЖ Сливки Домик в деревне стерилизованные 20% ...', '209,00 ₽', False],\n ['БЗМЖ Молоко пастер Кубанский Молочник отборное 1,4л ...',\n '154,99 ₽',\n False],\n ['БЗМЖ Сливки ОКЕЙ стерилизованные 20% 200мл тва', '46,99 ₽', True],\n ['БЗМЖ Сливки утп Село Зеленое 10% 200г', '62,99 ₽', False],\n ['БЗМЖ Напиток мол-коф Starbucks Cappuccino 220мл', '178,99 ₽', False],\n ['БЗМЖ Напиток мол-коф Starbucks Caramel Macchiato ...', '178,99 ₽', False],\n ['БЗМЖ Молоко пастер ОКЕЙ Daily 2,5% 1л пюр-пак', '42,89 ₽', False]]"
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"trusted": false
},
"id": "treated-particular",
"cell_type": "code",
"source": "right_arrow = driver.find_element(By.ID, \"WC_SearchBasedNavigationResults_pagination_link_right_categoryResults\")",
"execution_count": 49,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "exempt-insured",
"cell_type": "code",
"source": "right_arrow.click()\nsleep(1)",
"execution_count": 52,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "large-valley",
"cell_type": "code",
"source": "from time import sleep",
"execution_count": 53,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "embedded-occupation",
"cell_type": "code",
"source": "url = \"https://www.okeydostavka.ru/msk/molochnye-produkty-syry-iaitso/molochnye-produkty/moloko-i-slivki\"\ndriver.get(url)\n\nrows = []\nwhile True:\n print(\"#\")\n products = driver.find_elements(By.CSS_SELECTOR, \n \"div.product\")\n for product in products:\n name = product.find_element(By.CSS_SELECTOR, \"div.product-name\").text\n span_price = product.find_element(By.CSS_SELECTOR, \"span.price\")\n price = span_price.get_attribute(\"innerHTML\").strip()\n red_label = 'label-red' in span_price.get_attribute(\"class\")\n rows.append([name, price, red_label])\n \n right_arrow = driver.find_element(\n By.ID, \"WC_SearchBasedNavigationResults_pagination_link_right_categoryResults\")\n if not right_arrow.is_displayed():\n break\n right_arrow.click()\n sleep(3)",
"execution_count": 66,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "#\n#\n#\n"
}
]
},
{
"metadata": {
"trusted": false
},
"id": "spatial-mozambique",
"cell_type": "code",
"source": "import pandas as pd",
"execution_count": 68,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "south-hearts",
"cell_type": "code",
"source": "df = (pd.DataFrame(rows, columns=['name', 'price', 'red']).\n assign(price=lambda x: x['price'].str[:-2]\n .str.replace(\",\", \".\").astype(float)))",
"execution_count": 72,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "provincial-canada",
"cell_type": "code",
"source": "%matplotlib inline",
"execution_count": 74,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "fallen-occasions",
"cell_type": "code",
"source": "df['name'].str.replace(\" \", \"\")",
"execution_count": 81,
"outputs": [
{
"data": {
"text/plain": "0 БЗМЖМолокопастДомиквдеревнеДерОтб3,5-4,5%...\n1 БЗМЖКоктейльутпЧудошоколад3+0мл\n2 БЗМЖСливкиУТПпитевыеCampina10%10*17г\n3 БЗМЖСливкиPresidentвзбитые20%250г\n4 БЗМЖСливкиАльпенгуртпорционные10%10*10г\n ... \n160 БЗМЖМолокоутпParmalatComfortбезлактозное3,5%...\n161 БЗМЖМолокоутпParmalatComfortбезлактозное1,8%...\n162 БЗМЖМолокоутпParmalatComfortбезлактозное0,05%...\n163 БЗМЖСливкиParmalatComfortбезлактозные11%500г\n164 БЗМЖМолокопастертоплёноеЭконива4%1000мл\nName: name, Length: 165, dtype: object"
},
"execution_count": 81,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"trusted": false
},
"id": "reduced-deviation",
"cell_type": "code",
"source": "df['price'].hist()",
"execution_count": 75,
"outputs": [
{
"data": {
"text/plain": "<AxesSubplot:>"
},
"execution_count": 75,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAPHElEQVR4nO3df2xd9XnH8fdTAiXDXcKvWVGCZiqiVogMOiwKon/YYUyMVIU/ECqKuiBl8j+txLRMW9ikSZU2LWiirJOqqdFAzR9dDaOgIFBXsYBXTVqhSaEEyBgpC1sjlqhdyGqEupk9+8MnkWXse29s3x9P8n5J1j3ne871ee6T60+Ov77n3shMJEn1fKTfBUiSlsYAl6SiDHBJKsoAl6SiDHBJKmpVLw922WWX5cjIyKLb33vvPS666KLeFVSIvWnN/rRmf1ob9P4cOHDgp5l5+fzxngb4yMgI+/fvX3T71NQUY2NjvSuoEHvTmv1pzf60Nuj9iYi3Fxp3CkWSijLAJakoA1ySijLAJakoA1ySijLAJakoA1ySijLAJakoA1ySiurplZgVjex8pm/HPrJrS9+OLWnweQYuSUUZ4JJUlAEuSUUZ4JJUlAEuSUUZ4JJUlAEuSUUZ4JJUlAEuSUUZ4JJUlAEuSUUZ4JJUlAEuSUUZ4JJUlAEuSUUZ4JJUlAEuSUUZ4JJUVEcfqRYRR4CfAx8AM5k5GhGXAI8CI8AR4O7MPNGdMiVJ853JGfh4Zl6XmaPN+k5gX2ZuBPY165KkHlnOFModwJ5meQ9w57KrkSR1LDKz/U4R/wacABL4embujoh3M3Ntsz2AE6fW5913ApgAGB4evn5ycnLR40xPTzM0NLSEh9E9B4+e7NuxN61fc3p5EHszSOxPa/antUHvz/j4+IE5sx+ndTQHDnwmM49GxK8Az0bEv8zdmJkZEQv+T5CZu4HdAK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ySijLAJakoA1ySijLAJakoA1ySijLAJamo/wdxDnONLS9WsQAAAABJRU5ErkJggg==\n",
"text/plain": "<Figure size 432x288 with 1 Axes>"
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
]
},
{
"metadata": {
"trusted": false
},
"id": "comparable-amendment",
"cell_type": "code",
"source": "driver.find_element(By.ID, \"SimpleSearchForm_SearchTerm\").send_keys(\"сырок\")",
"execution_count": 83,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "molecular-quantity",
"cell_type": "code",
"source": "from selenium.webdriver.common.keys import Keys",
"execution_count": 84,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "acceptable-scott",
"cell_type": "code",
"source": "driver.find_element(By.ID, \"SimpleSearchForm_SearchTerm\").send_keys(Keys.ENTER)",
"execution_count": 85,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "funded-england",
"cell_type": "code",
"source": "driver.execute_script(\"window.scrollTo(0, document.body.scrollHeight);\")",
"execution_count": 87,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "hundred-authentication",
"cell_type": "code",
"source": "import requests",
"execution_count": 88,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "amazing-thanks",
"cell_type": "code",
"source": "r = requests.get()\nr.json()",
"execution_count": null,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "democratic-testimony",
"cell_type": "code",
"source": "import json",
"execution_count": 89,
"outputs": []
},
{
"metadata": {
"trusted": false
},
"id": "relative-interface",
"cell_type": "code",
"source": "json.loads('[\"Hello\", \"World\"]')",
"execution_count": 90,
"outputs": [
{
"data": {
"text/plain": "['Hello', 'World']"
},
"execution_count": 90,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"trusted": false
},
"id": "desirable-subscription",
"cell_type": "code",
"source": "",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"kernelspec": {
"name": "py39_system",
"display_name": "Python 3.9 (system)",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.9.0",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"gist": {
"id": "",
"data": {
"description": "Lesson22",
"public": false
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment