100일 코드 중 18일: BeautifulSoup을 사용하여 HTML의 링크 따라가기
CSS flexbox 챌린지 주제 사용 디스플레이, 트윗 포함에 플렉스 초능력 추가, flex-direction 속성을 사용하여 행 만들기, flex-direction 속성을 적용하여 트윗 포함에 행 생성, flex-direction 속성을 사용하여 작업 기둥 등을 만들다 Freecodecamp.
BeautifulSoup을 사용하여 HTML에서 링크 따라가기
프로그램은 라이브러리urllib.request, urllib.parse, urllib.error, BeautifulSoup를 가져오는 것으로 시작합니다.
import urllib.request, urllib.parse, urllib.error
from bs4 import BeautifulSoup
import re
프로그램은 urllib를 사용하여 아래 데이터 파일에서 HTML을 읽고, 앵커 태그에서 href= vaues를 추출하고, 목록의 이름과 관련된 특정 위치에 있는 태그를 스캔하고, 해당 링크를 따라가서 다음을 반복합니다. 여러 번 처리하고 찾은 성을 보고합니다.
url = "http://py4e-data.dr-chuck.net/known_by_Danni.html"
html = urllib.request.urlopen(url).read()
soup = BeautifulSoup(html, 'html.parser')
all_num_list = list()
link_position = 18
process_repeat = 3
tags = soup('a')
while process_repeat -1 >=0:
print('process round',process_repeat)
target = tags[link_position - 1]
print('target:',target)
url = target.get('href',2)
print('Current url',url)
html = urllib.request.urlopen(url).read()
soup = BeautifulSoup(html,"html.parser")
tags = soup('a')
process_repeat = process_repeat - 1
18일째 및 * CSS Flexbox 챌린지* 작업* 웹 데이터에 대한 파이썬 액세스 학습* 코드 2020의 출현*에 두 번째 챌린지 완료* BeautifulSoup을 사용하여 HTML의 링크pic.twitter.com/uS19iTqgXt — Durga Pokharel(@mathdurga)
Reference
이 문제에 관하여(100일 코드 중 18일: BeautifulSoup을 사용하여 HTML의 링크 따라가기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://dev.to/iamdurga/day-18-of-100days-of-code-following-links-in-html-using-beautifulsoup-35fj
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
import urllib.request, urllib.parse, urllib.error
from bs4 import BeautifulSoup
import re
url = "http://py4e-data.dr-chuck.net/known_by_Danni.html"
html = urllib.request.urlopen(url).read()
soup = BeautifulSoup(html, 'html.parser')
all_num_list = list()
link_position = 18
process_repeat = 3
tags = soup('a')
while process_repeat -1 >=0:
print('process round',process_repeat)
target = tags[link_position - 1]
print('target:',target)
url = target.get('href',2)
print('Current url',url)
html = urllib.request.urlopen(url).read()
soup = BeautifulSoup(html,"html.parser")
tags = soup('a')
process_repeat = process_repeat - 1
Reference
이 문제에 관하여(100일 코드 중 18일: BeautifulSoup을 사용하여 HTML의 링크 따라가기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/iamdurga/day-18-of-100days-of-code-following-links-in-html-using-beautifulsoup-35fj텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)