27 Mayıs 2024
23 Mayıs 2024
13 Mayıs 2024
import requests
# pip install requests
#
# status_code
# text
# headers
# timeout
#
# github a istek gönederelim
url = 'http://10.14.4.72:42001'#'http://10.10.10.128/dvwa/login.php'
#1) r = requests.get(url, allow_redirects=False) # yönlendirme yok
#headers={'user-agent':'btk-akademi/1.1.1'}
#2) r = requests.get(url, headers=headers, allow_redirects=False) # yönlendirme yok
data ={'username':'admin','password':'password','Login':'Login'}
try:
r = requests.post(url, data=data, allow_redirects=True, timeout=2.2) # 2 ok, 0.2 ok, 0.02 timeout
print(r.status_code) # https için 200, http için 301 içerik yok(yönlendirme olmayınca)
print(r.text) # içerik content
print(r.headers)
print(r.headers.get('Date'))
print(r.headers.get('Content-Type'))
print(r.headers.get('server'))
except Exception as e:
print(e)
pass
# bu bir sürü değerler json ise , bunlarından içinden istediğimiz vilgiyi çekebiliriz
# render öncesi kodlar gelir, javascripler gelir
"""
try:
pass
except:
pass
else:
pass
finally:
pass
"""
Kaydol:
Kayıtlar (Atom)