extractHTMLText
HTML에서 텍스트 추출
구문
설명
예제
HTML 코드에서 텍스트 데이터를 바로 추출하려면 extractHTMLText를 사용하고 HTML 코드를 string형으로 지정하십시오.
code = "<html><body><h1>THE SONNETS</h1><p>by William Shakespeare</p></body></html>";
str = extractHTMLText(code)str =
"THE SONNETS
by William Shakespeare"
웹 페이지에서 텍스트 데이터를 추출하려면 먼저 webread 함수를 사용하여 HTML 코드를 읽어오십시오. 그런 다음 반환된 코드에 extractHTMLText 함수를 사용합니다.
url = "https://www.mathworks.com/help/textanalytics";
code = webread(url);
str = extractHTMLText(code)str =
'Text Analytics Toolbox
Analyze and model text data
Release Notes
PDF Documentation
Release Notes
PDF Documentation
Text Analytics Toolbox™ provides algorithms and visualizations for preprocessing, analyzing, and modeling text data. Models created with the toolbox can be used in applications such as sentiment analysis, predictive maintenance, and topic modeling.
Text Analytics Toolbox includes tools for processing raw text from sources such as equipment logs, news feeds, surveys, operator reports, and social media. You can extract text from popular file formats, preprocess raw text, extract individual words, convert text into numerical representations, and build statistical models.
Using machine learning techniques such as LSA, LDA, and word embeddings, you can find clusters and create features from high-dimensional text datasets. Features created with Text Analytics Toolbox can be combined with features from other data sources to build machine learning models that take advantage of textual, numeric, and other types of data.
Get Started
Learn the basics of Text Analytics Toolbox
Text Data Preparation
Import text data into MATLAB® and preprocess it for analysis
Modeling and Prediction
Develop predictive models using topic models and word embeddings
Display and Presentation
Visualize text data and models using word clouds and text scatter plots
Language Support
Information on language support in Text Analytics Toolbox'
webread 함수를 사용하여 URL https://www.mathworks.com/help/textanalytics에서 HTML 코드를 읽어옵니다.
url = "https://www.mathworks.com/help/textanalytics";
code = webread(url);htmlTree를 사용하여 HTML 코드를 구문 분석합니다.
tree = htmlTree(code);
findElement를 사용하여 HTML 트리에서 하이퍼링크를 모두 찾습니다. 하이퍼링크는 요소 이름이 "A"인 노드입니다.
selector = "A";
subtrees = findElement(tree,selector);처음 몇 개의 하위 트리를 표시합니다.
subtrees(1:10)
ans =
10×1 htmlTree:
<A class="skip_link sr-only" href="#content_container">Skip to content</A>
<A href="https://www.mathworks.com?s_tid=gn_logo" class="svg_link navbar-brand"><IMG src="/images/responsive/global/pic-header-mathworks-logo.svg" class="mw_logo" alt="MathWorks"/></A>
<A href="https://www.mathworks.com/products.html?s_tid=gn_ps">Products</A>
<A href="https://www.mathworks.com/solutions.html?s_tid=gn_sol">Solutions</A>
<A href="https://www.mathworks.com/academia.html?s_tid=gn_acad">Academia</A>
<A href="https://www.mathworks.com/support.html?s_tid=gn_supp">Support</A>
<A href="https://www.mathworks.com/matlabcentral/?s_tid=gn_mlc">Community</A>
<A href="https://www.mathworks.com/company/events.html?s_tid=gn_ev">Events</A>
<A href="https://www.mathworks.com/products/get-matlab.html?s_tid=gn_getml">Get MATLAB</A>
<A href="https://www.mathworks.com?s_tid=gn_logo" class="svg_link pull-left"><IMG src="/images/responsive/global/pic-header-mathworks-logo.svg" class="mw_logo" alt="MathWorks"/></A>
extractHTMLText를 사용하여 하위 트리에서 텍스트를 추출합니다. 추출한 결과에 해당 페이지에 있는 각 링크의 링크 텍스트가 들어 있습니다.
str = extractHTMLText(subtrees); str(1:10)
ans = 10×1 string
"Skip to content"
""
"Products"
"Solutions"
"Academia"
"Support"
"Community"
"Events"
"Get MATLAB"
""
입력 인수
HTML 코드로, string형 배열, 문자형 벡터 또는 문자형 벡터로 구성된 셀형 배열로 지정됩니다.
팁
웹 페이지에서 HTML 코드를 읽어오려면
webread를 사용하십시오.HTML 파일에서 텍스트를 추출하려면
extractFileText를 사용하십시오.
예: "<a href='https://www.mathworks.com'>MathWorks</a>"
데이터형: char | string | cell
HTML 트리로, htmlTree 배열로 지정됩니다.
추출 방법으로, 다음 중 하나로 지정됩니다.
| 옵션 | 설명 |
|---|---|
'tree' | DOM 트리와 텍스트 내용을 분석한 후 단락 블록을 추출합니다. |
'article' | 기사 텍스트를 검출하고 단락 블록을 추출합니다. |
'all-text' | 스크립트와 CSS 스타일을 제외하고, HTML 본문의 모든 텍스트를 추출합니다. |
버전 내역
R2018a에 개발됨
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)