실습
파이썬3 및 Atom 에디터를 설치하지 않았다면 <파이썬3 설치 하기> 영상을 보고 설치해주시기 바랍니다.
모든 실습은 자신의 PC 환경에서 진행하는걸 권장하며 Atom 에디터가 아닌 다른 텍스트 에디터를 사용해도 무관합니다. (ex: Sublime Text, Pycharm 등)
실습
파이썬3 및 Atom 에디터를 설치하지 않았다면 <파이썬3 설치 하기> 영상을 보고 설치해주시기 바랍니다.
모든 실습은 자신의 PC 환경에서 진행하는걸 권장하며 Atom 에디터가 아닌 다른 텍스트 에디터를 사용해도 무관합니다. (ex: Sublime Text, Pycharm 등)
최종 코드
반드시 영상을 보시고 직접 실행해보시고, 아래 제시된 최종 코드는 참고만 하시기 바랍니다.
# To run this, you can install BeautifulSoup
# https://pypi.python.org/pypi/beautifulsoup4
# Or download the file
# http://www.py4e.com/code3/bs4.zip
# and unzip it in the same directory as this file
import urllib.request, urllib.parse, urllib.error
from bs4 import BeautifulSoup
import ssl
# Ignore SSL certificate errors
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
url = input('Enter - ')
html = urllib.request.urlopen(url, context=ctx).read()
soup = BeautifulSoup(html, 'html.parser')
# Retrieve all of the anchor tags
tags = soup('a')
for tag in tags:
print(tag.get('href', None))
comment
https://www.si.umoch.edu/ 여기사이트 접근권한이 있어야하나요? 에러나는데..
https://davidbpython.com/amadeus/python_data/dormouse.html 예시 url
2022.06.06 완료!!!