Created
July 6, 2017 13:51
-
-
Save jnovikov/bc53364a883a1b38006855552b546af5 to your computer and use it in GitHub Desktop.
Python requests example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
import requests | |
url = 'http://web7.shadowservants.ru' | |
r = requests.get(url) | |
# Получить список кукизов | |
print(r.cookies.items()) | |
print(r.text) | |
# Отправка своих кукизов | |
own_cookies = {'is_admin':'1'} | |
r = requests.get(url,cookies=own_cookies) | |
print(r.text) | |
url = 'http://127.0.0.1:5000' | |
data = {'login':'keker'} | |
#Ведет себя как браузер. Запоминает куки для след реквеста | |
sess = requests.session() | |
sess.post(url+'/set',data=data) | |
r = sess.get(url) | |
print(r.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment