簡體   English   中英

在 MySQL 5.7 中提取 HTML 標記內的數據

[英]Extract data inside HTML tags in MySQL 5.7

我正在嘗試從 html 標簽中獲取額外的數據。 我創建了一個函數來充當 t-sql 中的 split_string。 盡管它不能始終如一地工作,並且想知道其他人發現了什么。 我將嘗試包含一個示例,但它可能無法正常工作,因為它上面到處都是 html 標簽。

<div class="sub-sub-head"><b>Overview:</b></div>Establish and maintain an accurate, detailed, and up-to-date inventory of all enterprise assets with the potential to store or process data, to include: end-user devices (including portable and mobile), network devices, non-computing/IoT devices, and servers. Ensure the inventory records the network address (if static), hardware address, machine name, data asset owner, department for each asset, and whether the asset has been approved to connect to the network. For mobile end-user devices, MDM type tools can support this process, where appropriate. This inventory includes assets connected to the infrastructure physically, virtually, remotely, and those within cloud environments. Additionally, it includes assets that are regularly connected to the enterprise’s network infrastructure, even if they are not under control of the enterprise. Review and update the inventory of all enterprise assets bi-annually, or more frequently.<br/><br/>
 
 <div class="sub-sub-head"><b>Action Items:</b></div>1) Maintain a detailed Hardware Asset Inventory.<br/>
 
 <div class="sub-sub-head"><b>Additional Guidance:</b> </div>Asset Type: Devices <br> <br>
 Security Function: Identify

使用 substring_index 進行拆分; 對於每個字段,您調用它兩次,一次獲取前 N 個字段,一次獲取最后一個字段:

select
    substring_index(substring_index(bar, '<div class="sub-sub-head">', 2), '<div class="sub-sub-head">', -1) overview,
    substring_index(substring_index(bar, '<div class="sub-sub-head">', 3), '<div class="sub-sub-head">', -1) action_items,
    substring_index(substring_index(bar, '<div class="sub-sub-head">', 4), '<div class="sub-sub-head">', -1) guidance
from foo;

小提琴

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM