Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
MorvanZhou committed Dec 30, 2017
1 parent 9e6e6b1 commit b5d461b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
18 changes: 9 additions & 9 deletions notebook/3-1-requests.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {
"collapsed": false
},
Expand All @@ -28,7 +28,7 @@
"True"
]
},
"execution_count": 4,
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -148,14 +148,14 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'loggedin': '1', 'username': 'Morvan'}\n"
"{'username': 'Morvan', 'loggedin': '1'}\n"
]
},
{
Expand All @@ -167,12 +167,12 @@
}
],
"source": [
"sess = requests.Session()\n",
"session = requests.Session()\n",
"payload = {'username': 'Morvan', 'password': 'password'}\n",
"s = sess.post('http://pythonscraping.com/pages/cookies/welcome.php', data=payload)\n",
"print(s.cookies.get_dict())\n",
"s = sess.get(\"http://pythonscraping.com/pages/cookies/profile.php\")\n",
"print(s.text)"
"r = session.post('http://pythonscraping.com/pages/cookies/welcome.php', data=payload)\n",
"print(r.cookies.get_dict())\n",
"r = session.get(\"http://pythonscraping.com/pages/cookies/profile.php\")\n",
"print(r.text)"
]
},
{
Expand Down
11 changes: 5 additions & 6 deletions source_code/3-1-requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ def post_login():
def session_login():
print('\nsession login')
# http://pythonscraping.com/pages/cookies/login.html
sess = requests.Session()
session = requests.Session()
payload = {'username': 'Morvan', 'password': 'password'}

s = sess.post('http://pythonscraping.com/pages/cookies/welcome.php', data=payload)
print(s.cookies.get_dict())
s = sess.get("http://pythonscraping.com/pages/cookies/profile.php")
print(s.text)
r = session.post('http://pythonscraping.com/pages/cookies/welcome.php', data=payload)
print(r.cookies.get_dict())
r = session.get("http://pythonscraping.com/pages/cookies/profile.php")
print(r.text)


get()
Expand Down

0 comments on commit b5d461b

Please sign in to comment.