{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "BVHKH4FKf_hu"
   },
   "source": [
    "## requests 簡介\n",
    "\n",
    "在爬蟲中,我們會使用 requests 把原始資料從網頁伺服器 (Web Server) 中讀取回來。\n",
    "\n",
    "* 使用 get 方法讀取網站原始碼\n",
    "\n",
    "```python\n",
    "r = requests.get(url)\n",
    "```\n",
    "\n",
    "* 使用 post 方法讀取網站原始碼\n",
    "\n",
    "```python\n",
    "r = requests.post(url, data=data)\n",
    "```\n",
    "\n",
    "參考連結:[Python Requests.Quickstart](http://docs.python-requests.org/en/master/user/quickstart/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "acsqCGGXhGHp"
   },
   "outputs": [],
   "source": [
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "qB4uJ_FSxthl"
   },
   "outputs": [],
   "source": [
    "r = requests.get('https://victorgau.github.io/python_crawler/example01.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "Nf1E-vlRx7lY"
   },
   "outputs": [],
   "source": [
    "r.encoding"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "xo_nhKyDx6fR"
   },
   "outputs": [],
   "source": [
    "print(r.text)"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "collapsed_sections": [],
   "name": "requests 簡介.ipynb",
   "provenance": []
  },
  "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.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}