{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "automotive-trailer", "metadata": {}, "outputs": [], "source": [ "from selenium import webdriver\n", "chromeOptions = webdriver.ChromeOptions()\n", "driver = webdriver.Chrome('./chromedriver', chrome_options=chromeOptions)" ] }, { "cell_type": "code", "execution_count": null, "id": "physical-croatia", "metadata": {}, "outputs": [], "source": [ "driver.get(\"https://github.com/PaddlePaddle/PaddleSpeech/graphs/contributors\")" ] }, { "cell_type": "code", "execution_count": null, "id": "seventh-latitude", "metadata": {}, "outputs": [], "source": [ "

\n", " \n", " \"zh794390558\"\n", " \n", " #1\n", " zh794390558\n", " \n", " \n", "
\n", " 655 commits\n", "   \n", " 3,671,956 ++\n", "   \n", " 1,966,288 --\n", "
\n", "
\n", "
\n", "

" ] }, { "cell_type": "code", "execution_count": null, "id": "modified-argument", "metadata": {}, "outputs": [], "source": [ "from selenium.webdriver.common.by import By" ] }, { "cell_type": "code", "execution_count": null, "id": "demonstrated-aging", "metadata": {}, "outputs": [], "source": [ "elements = driver.find_elements(By.CLASS_NAME, 'lh-condensed')\n", "for element in elements:\n", " zhuye = element.find_elements(By.CLASS_NAME, 'd-inline-block')[0].get_attribute(\"href\")\n", " img = element.find_elements(By.CLASS_NAME, 'avatar')[0].get_attribute(\"src\")\n", " mkdown = f\"\"\"\"\"\"\n", " print(mkdown)" ] }, { "cell_type": "code", "execution_count": null, "id": "general-torture", "metadata": {}, "outputs": [], "source": [ "element.find_elements(By.CLASS_NAME, 'd-inline-block')[0].get_attribute(\"href\")" ] }, { "cell_type": "code", "execution_count": null, "id": "downtown-institute", "metadata": {}, "outputs": [], "source": [ "element.find_elements(By.CLASS_NAME, 'avatar')[0].get_attribute(\"src\")" ] }, { "cell_type": "code", "execution_count": null, "id": "worthy-planet", "metadata": {}, "outputs": [], "source": [ "len(elements)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.7.0" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 5 }