2022. 9. 26. 12:31ㆍAI/프로그래머스 AI 코스
HTTP request
GET / HTTP 1.1
HOST: www.programmers.com
User-Agent : Mozilla / 5.0
request - response 구조(client - server)
HTTP/1.1 200 OK
HEAD, BODY 구조
response
state 200, 300, 404, 500 ...
https://developer.mozilla.org/ko/docs/Web/HTTP/Status
HTTP 상태 코드 - HTTP | MDN
HTTP 응답 상태 코드는 특정 HTTP 요청이 성공적으로 완료되었는지 알려줍니다. 응답은 5개의 그룹으로 나누어집니다: 정보를 제공하는 응답, 성공적인 응답, 리다이렉트, 클라이언트 에러, 그리고
developer.mozilla.org
웹사이트, 웹페이지
HTML(HyperText Markup Language) 형식의 웹페이지의 묶음이 웹사이트
웹브라우저
HTTP request, 응답받은 HTML 코드를 랜더링
HTML5
<!DOCTYPE html> ... 버전 명시
Import
import request
GET
url = 'https://www.naver.com')
res = requests.get(url)
response 는 object로 받는다
HEAD, BODY 확인
res.headers
res.text
POST
* Webhook : https://leffept.tistory.com/329
[Webhook]웹훅이란?
Webhook 이란? "A webhook in web development is a method of augmenting or altering the behavior of a web page or web application with custom callbacks." (위키피디아 발췌) 위키피디아의 설명에..
leffept.tistory.com
웹페이지, 웹 앱에서 발생하는 이벤트를 callback 방식으로 처리한다 (Pooling 방식이 아닌 Event 처리 방식)
Webhook.site : https://webhook.site/
payload = {'name': "Hello",
"age": 13}
res = requests.post('https://webhook.site/3f75e95c-e314-4129-b76d-b506bd659f92', payload)
res.status_code
post 결과
웹 스크랩핑
RES(Robots Exclusion Standard)
robots.txt
User-agent 정보 확인
User-agent : 규칙이 적용될 로봇의 이름
Disallow : / 차단될 URL
Allow : / 허용될 URL
res = requests.get('https://naver.com/robots.txt')
print(res.text)
User-agent: * # 모든 사용자
Disallow: / # root부터 하위 모두 거절
Allow : /$ # /$ 만 허용(root 까지만 허용)
https://developers.google.com/search/docs/advanced/robots/create-robots-txt?hl=ko
robots.txt 파일 만들기 및 제출 | Google 검색 센터 | 문서 | Google Developers
robots.txt 파일은 사이트의 루트에 위치합니다. robots.txt 파일을 만들고 예를 확인하며 robots.txt 규칙을 확인하는 방법을 알아보세요.
developers.google.com
https://developers.google.com/search/docs/advanced/robots/robots_txt?hl=ko
Google에서 robots.txt 사양을 해석하는 방법 | 문서 | Google Developers
다양한 robots.txt 파일 규칙과 Google이 robots.txt 사양을 해석하는 방법을 자세히 알아보세요.
developers.google.com
참고 페이지
https://developer.mozilla.org/ko/docs/Web/HTTP
HTTP | MDN
하이퍼텍스트 전송 프로토콜(HTTP)은 HTML과 같은 하이퍼미디어 문서를 전송하기위한 애플리케이션 레이어 프로토콜입니다. 웹 브라우저와 웹 서버간의 커뮤니케이션을위해 디자인되었지만, 다
developer.mozilla.org
'AI > 프로그래머스 AI 코스' 카테고리의 다른 글
Flask (0) | 2022.10.13 |
---|---|
Git 요약 (0) | 2022.10.04 |
MySQL (0) | 2022.09.28 |
Selenium (0) | 2022.09.28 |
BeautifulSoup4 (0) | 2022.09.27 |