[1099] Extract the text from HTML
Here's an example using Python with the BeautifulSoup library to get the text inside the <option>
tags:
from bs4 import BeautifulSoup html = ''' <option selected="selected" value="47">Approval under Control of Burning Reg</option> <option value="51">Court Ordered Modification</option> <option value="69">EHC Licence</option> <option value="52">Licence Bulk Variation</option> <option value="3">Load Reduction Agreement</option> <option value="4">Load Reduction Agreement - Termination</option> <option value="33">Penalty Notice</option> <option value="72">PRCE Act - s.36 Compliance Notice</option> <option value="74">PRCE Act - s.44 Revocation Notice</option> <option value="73">PRCE Act - s.44 Variation Notice</option> <option value="57">s.104(1) Payment of Costs & Expenses - Licensed</option> <option value="60">s.104(1) Payment of Costs and Expenses - Non Licensed</option> <option value="58">s.104(2) Payment of Costs & Expenses - Licensed</option> <option value="61">s.104(2) Payment of Costs and Expenses - Non Licensed</option> <option value="59">s.104(3) Payment of Costs & Expenses - Licensed</option> <option value="62">s.104(3) Payment of Costs and Expenses - Non Licensed</option> <option value="29">s.110 Revocation of Clean Up Notice</option> <option value="34">s.110 Revocation of Prevention Notice</option> <option value="37">s.110 Variation of Clean Up Notice</option> <option value="36">s.110 Variation of Prevention Notice</option> <option value="24">s.264 Noise Control Notice</option> <option value="68">s.276 Noise Abatement Direction</option> <option value="9">s.55 Licence Refusal</option> <option value="38">s.55 Licence Transfer</option> <option value="10">s.55 Licence Transfer Refusal</option> <option value="12">s.58 Licence Variation</option> <option value="49">s.78G Exemption - Cruise Shipping</option> <option value="50">s.78N Approval - Cruise Shipping</option> <option value="13">s.79 Revocation of a Licence</option> <option value="15">s.79 Suspension of a Licence</option> <option value="16">s.80 Surrender of a Licence</option> <option value="25">s.81 Variation of a Revocation Condition</option> <option value="39">s.81 Variation of a Surrender Condition</option> <option value="67">s.81(3) Variation of a Suspension Condition</option> <option value="71">s.91 Clean Up Notice</option> <option value="64">s.91A Supplementary Clean Up Action</option> <option value="76">s.92 - s.108A Clean-up Action</option> <option value="48">s.92 Clean Up Notice</option> <option value="22">s.96 Prevention Notice</option> <option value="66">s.96A Supplementary Prevention Notice</option> ''' soup = BeautifulSoup(html, 'html.parser') texts = [option.get_text() for option in soup.find_all('option')] print(texts)
This code will output a list of the text content inside each <option>
tag:
['Approval under Control of Burning Reg', 'Court Ordered Modification', 'EHC Licence', 'Licence Bulk Variation', 'Load Reduction Agreement', 'Load Reduction Agreement - Termination', 'Penalty Notice', 'PRCE Act - s.36 Compliance Notice', 'PRCE Act - s.44 Revocation Notice', 'PRCE Act - s.44 Variation Notice', 's.104(1) Payment of Costs & Expenses - Licensed', 's.104(1) Payment of Costs and Expenses - Non Licensed', 's.104(2) Payment of Costs & Expenses - Licensed', 's.104(2) Payment of Costs and Expenses - Non Licensed', 's.104(3) Payment of Costs & Expenses - Licensed', 's.104(3) Payment of Costs and Expenses - Non Licensed', 's.110 Revocation of Clean Up Notice', 's.110 Revocation of Prevention Notice', 's.110 Variation of Clean Up Notice', 's.110 Variation of Prevention Notice', 's.264 Noise Control Notice', 's.276 Noise Abatement Direction', 's.55 Licence Refusal', 's.55 Licence Transfer', 's.55 Licence Transfer Refusal', 's.58 Licence Variation', 's.78G Exemption - Cruise Shipping', 's.78N Approval - Cruise Shipping', 's.79 Revocation of a Licence', 's.79 Suspension of a Licence', 's.80 Surrender of a Licence', 's.81 Variation of a Revocation Condition', 's.81 Variation of a Surrender Condition', 's.81(3) Variation of a Suspension Condition', 's.91 Clean Up Notice', 's.91A Supplementary Clean Up Action', 's.92 - s.108A Clean-up Action', 's.92 Clean Up Notice', 's.96 Prevention Notice', 's.96A Supplementary Prevention Notice']
Feel free to use this code as needed! If you have any further questions or need additional help, I'm here for you.
分类:
Python Study
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 如何使用 Uni-app 实现视频聊天(源码,支持安卓、iOS)
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
2018-02-19 【303】C# 复制窗体 & 修改名称
2018-02-19 【302】C# TreeView 控件使用说明
2018-02-19 【301】IDL与C#混合编程
2014-02-19 【137】Photoshop相关功能