{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import selenium\n", "import time\n", "import datetime\n", "from selenium import webdriver\n", "from selenium.webdriver.common.desired_capabilities import DesiredCapabilities\n", "from bs4 import BeautifulSoup\n", "\n", "from IPython.display import display, Image, HTML\n", "\n", "from jupyter_progressbar import ProgressBar\n", "import json" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "def remove_kickstarter_url_prefix(url):\n", " if url.startswith('https://www.kickstarter.com/'):\n", " return url[len('https://www.kickstarter.com'):]\n", " return url" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "driver = webdriver.Chrome()\n", "\n", "root = 'https://www.kickstarter.com/'\n", "driver.get(root)\n", "\n", "discover_links = {\n", " link\n", " for link in driver.find_elements_by_tag_name('a')\n", " for link in [link.get_attribute('href')]\n", " for link in [remove_kickstarter_url_prefix(link)]\n", " if link.startswith(\"/discover/\")\n", "}\n", "\n", "driver.close()\n", "driver.quit()" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Request-sent\n" ] } ], "source": [ "try:\n", " driver.close()\n", " driver.quit()\n", "except Exception as e:\n", " print(e)\n", "\n", "driver = webdriver.Chrome()" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "scrolled": false }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "990f33c96fef49aebb4caaf7df72e20f", "version_major": 2, "version_minor": 0 }, "text/html": [ "
Failed to display Jupyter Widget of type VBox
.
\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "
\n", "\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "
\n" ], "text/plain": [ "VBox(children=(HBox(children=(FloatProgress(value=0.0, max=1.0), HTML(value='0s passed', placeholder='0%'))), HTML(value='0% or 0 of 0 done', placeholder='0%')))" ] }, "metadata": {}, "output_type": "display_data" }, { "ename": "KeyboardInterrupt", "evalue": "", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", "\u001b[0;32m