파이썬 requests
-
[ Python ] requests 모듈 다양한 이용Python/Python Programming 2023. 5. 25. 11:05
설치 : pip install requests 1. Response Text. (Text 출력) import requests with requests.Session() as s: r = s.get(site) print(r.text) 2. Response Status Code. (응답코드 출력) import requests with requests.Session() as s: r = s.get(site) print(r.status_code) 3. Response Encoding. (Encoding 출력) import requests with requests.Session() as s: r = s.get(site) print(r.encoding) 4. Response Hearders. (Hearders 출력..
-
[Python] website basic monitoring usging requests module (웹 사이트 모니터링)System ManageMent 2018. 5. 5. 16:33
파이썬(python) requests 모듈을 이용한 간단한 웹 사이트 모니터링. import requests import time from datetime import datetime url = ('url1','url2','url3') # tuple while True: for site in url: with requests.Session() as s: r = s.get(site) if r.status_code == 200: # r.status_code : response status print('%s is ok : Response Status : %d' %(site, r.status_code)) else: print('%s is Check : Response Status : %d' % (site, r...