pip install requests
Requirement already satisfied: requests in /usr/local/lib/python3.7/site-packages (2.25.1)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/site-packages (from requests) (2020.12.5)
Requirement already satisfied: chardet<5,>=3.0.2 in /usr/local/lib/python3.7/site-packages (from requests) (4.0.0)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/site-packages (from requests) (2.10)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.7/site-packages (from requests) (1.26.3)
WARNING: You are using pip version 21.0; however, version 21.0.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
Note: you may need to restart the kernel to use updated packages.
from requests import session
payload = {
'action': 'login',
'id':'0165afeb-4a98-470c-a2d4-66dd806bde1d'
}
with session() as c:
c.post('http://206.189.52.145:5000/stage/', data=payload)
response = c.get('http://206.189.52.145:5000/stage/login?id=0165afeb-4a98-470c-a2d4-66dd806bde1d')
print(response.headers)
print(response.text)
{'Content-Type': 'text/html; charset=utf-8', 'Content-Length': '84', 'Access-Control-Allow-Origin': '*'}
Welcome (g) to (e) this (t) task (h) please (e) save (l) your (p) UUID4, Let's Go :D
!pip install bs4==0.0.1
Collecting bs4==0.0.1
Downloading bs4-0.0.1.tar.gz (1.1 kB)
Collecting beautifulsoup4
Downloading beautifulsoup4-4.9.3-py3-none-any.whl (115 kB)
|████████████████████████████████| 115 kB 15.2 MB/s
Collecting soupsieve>1.2
Downloading soupsieve-2.1-py3-none-any.whl (32 kB)
Building wheels for collected packages: bs4
Building wheel for bs4 (setup.py) ... done
Created wheel for bs4: filename=bs4-0.0.1-py3-none-any.whl size=1273 sha256=bcec3a1d2ad46fdf164d53ce0783c82188ec904c2c1ca0c211a71c8f4a3df367
Stored in directory: /root/.cache/pip/wheels/0a/9e/ba/20e5bbc1afef3a491f0b3bb74d508f99403aabe76eda2167ca
Successfully built bs4
Installing collected packages: soupsieve, beautifulsoup4, bs4
Successfully installed beautifulsoup4-4.9.3 bs4-0.0.1 soupsieve-2.1
WARNING: You are using pip version 21.0; however, version 21.0.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
!pip install bs4==0.0.1
Requirement already satisfied: bs4==0.0.1 in /usr/local/lib/python3.7/site-packages (0.0.1)
Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.7/site-packages (from bs4==0.0.1) (4.9.3)
Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.7/site-packages (from beautifulsoup4->bs4==0.0.1) (2.1)
WARNING: You are using pip version 21.0; however, version 21.0.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
from requests import Session
from bs4 import BeautifulSoup as bs
with Session() as s:
site = s.get("http://206.189.52.145:5000/stage/login")
bs_content = bs(site.content, "html.parser")
token = bs_content.find("input", {"name":"csrf_token"})["value"]
login_data = {"username":"admin","password":"12345", "csrf_token":token}
s.post("http://206.189.52.145:5000/stage/login",login_data)
home_page = s.get("http://206.189.52.145:5000/stage")
print(home_page.content)
TypeError: 'NoneType' object is not subscriptable