tags 相关问题

标签是标记或语义描述符。尽管通用起源,这个“标签”已成为HTML的同义词 - 如果你的问题已经在这个背景下,它的使用可能是不必要的。然而,在不同的上下文中,术语“标签”也可以正式使用。一个案例是SCADA程序Ignition,其中标签是放置在分层系统中的基本单元之一,每个单元都有自己的标签路径和与其他标签相关的标签路径。

Python:删除两个给定 HTML 标签之间的所有内容

选择的编程语言是Python。 这是我的 HTML 文本: 原消息 选择的编程语言是Python。 这是我的 HTML 文本: <a href="https://www.example.com">Original message</a><br> <ul id="list"> <li class="blockbody" id="post_1"> <div class="header"> <div class="datetime"> 24 januari 2020, 11:34 </div><span class="name">Jane Doe</span> </div> <div class="content"> <blockquote class="restore"> <div class="bbcode_container"> <i class="fa fa-envelope"></i> Citation: <div class="bbcode_quote printable"> <hr> <div> Citation: John Doe <a href="showthread.php#post684209" rel="nofollow"><img alt="" class="inlineimg" src="image/style/Aesthetica/button/view.gif"></a> </div> <div class="message"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div> <hr> </div> </div><br> <div class="bbcode_container"> <i class="fa fa-envelope"></i> Citation: <div class="bbcode_quote printable"> <hr> Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum?<br> <br> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.<br> <br> quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.. <hr> </div> </div>... <a href="https://example.com" target="_blank">https://example.html</a><br> <br> velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum? </blockquote> </div> </li> </ul> 我想删除 THE FIRST <div class="bbcode_quote printable"> 和 THE LAST <hr> 标签之间的所有内容。正如您所看到的,这两个标签都有多个实例,这就是为什么我强调第一个和最后一个。 我熟悉 Python,但字符串操作不是我的专业领域。 我希望我已经说清楚了。 您可以使用 Beautiful Soup 库 - https://pypi.org/project/beautifulsoup4/ 参考: 使用BeautifulSoup查找具有两种特定样式的标签 如何删除特定 html 标签内的所有内容(以及标签本身) from bs4 import BeautifulSoup # The HTML string provided html = """ <a href="https://www.example.com">Original message</a><br> <ul id="list"> <li class="blockbody" id="post_1"> <div class="header"> <div class="datetime"> 24 januari 2020, 11:34 </div><span class="name">Jane Doe</span> </div> <div class="content"> <blockquote class="restore"> <div class="bbcode_container"> <i class="fa fa-envelope"></i> Citation: <div class="bbcode_quote printable"> <hr> <div> Citation: John Doe <a href="showthread.php#post684209" rel="nofollow"><img alt="" class="inlineimg" src="image/style/Aesthetica/button/view.gif"></a> </div> <div class="message"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div> <hr> </div> </div><br> <div class="bbcode_container"> <i class="fa fa-envelope"></i> Citation: <div class="bbcode_quote printable"> <hr> Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum?<br> <br> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.<br> <br> quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.. <hr> </div> </div>... <a href="https://example.com" target="_blank">https://example.html</a><br> <br> velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum? </blockquote> </div> </li> </ul> """ soup = BeautifulSoup(html, 'html.parser') # Find the first div with class "bbcode_quote printable" first_quote = soup.find('div', class_='bbcode_quote printable') # Find all hr tags in the first div, get the last hr tag last_hr = first_quote.find_all('hr')[-1] # Extract all contents between the first hr and the last hr start = first_quote.hr end = last_hr # Extract all elements between these two tags current = start.find_next_sibling() while current and current != end: current.extract() current = start.find_next_sibling() # This will remove the first <hr> also, if you want to keep it uncomment below line # last_hr.extract() # Optionally remove the last <hr> as well, depending on requirements # Print the modified HTML print(str(soup))

回答 1 投票 0

如何通过关系使用has_many批量更新插入标签到rails中的记录?

假设我有一个帖子的经典示例,它通过标签连接表有很多标签。我将如何着手将特定标签一次插入到满足特定条件的多个帖子中。 在

回答 1 投票 0

Terraform 根据变量创建 AWS 标签和值

我们的 AWS 基础设施中有不同的环境,这些环境存储在 CloudFormation 导出中。我每天自动关闭开发环境,并检查脚本是否存在

回答 1 投票 0

如果我想在 telegram python 机器人中标记群组的所有成员,我该怎么办?

我有一个在 python 上运行并基于 telethon 库的电报机器人。我想标记群组中的所有成员,但我的代码源有 100 个用户标记限制,当我想将其计数增加到 500

回答 2 投票 0

在 tkinter 中独立更改颜色或多个形状

我想创建一个程序,可以通过单击鼠标来切换许多方块的颜色。我能够创建形状并切换颜色。 我的问题是有很多正方形。我的“变色&

回答 1 投票 0

标记远程 git 存储库而不克隆它

有没有办法在不克隆本地的情况下标记远程 git 存储库? 为了将代码存储库与配置存储库关联起来,我想(作为 CI 构建步骤)标记任何内容

回答 4 投票 0

为ChildComponent添加动态html属性

我想在html中向我的ChildComponent添加一个动态html属性,例如hits: 我不想用它作为输入,只需要我...

回答 1 投票 0

角度 |为子组件添加动态 html 属性

我想在 html 中向我的子组件添加动态 html 属性,例如点击: 我不想用它作为输入,只需要我...

回答 1 投票 0

如何从表单中的用户获取标签并将其保存到django中的数据库

我有一个表单,可以从用户那里获取一些字段和标签,并将用户输入数据保存在数据库中: 顺便说一下我正在使用 taggit 这是我的模型: 从 taggit.managers 导入 TaggableManager 班级

回答 1 投票 0

如何在bs4.element.ResultSet类型对象中查找标签

我正在学习/进行网页抓取并遇到一个问题,我有一个 bs4.element.ResultSet 类型的对象 其中包含一些 div 标签,我想像在 bs4.BeautifulSoup 类型对象中那样提取它

回答 2 投票 0

无法使用selenium pthon从HTML页面获取多个类下的标签值

我想从以下 HTML 中提取“xms” ... 我想从以下 HTML 中提取“xms” <div class="ki-kullaniciadi member-info" member-info-memberid="12789" member-info-forumid="2613"> <a href="/profil/12789"> <b>xms</b> </a> </div> 我已经尝试过了 def scrapecomments2(url): tic = time.perf_counter() wait = WebDriverWait(wd,20) wd.get(url) data2=[] for comment in wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "div.ki-kullaniciadi.member-info b"))): data2.append(comment.text) toc = time.perf_counter() print(data2) return data2 包括许多组合,例如 for comment in wait.until(EC.presence_of_all_elements_located((By.CLASS_NAME, "ki-kullaniciadi b"))): data2.append(comment.text) for comment in wait.until(EC.presence_of_all_elements_located((By.XPATH,"//div[@class='ki-kullaniciadi']/a/b"))): data2.append(comment.text) 它总是回来 TimeoutException Traceback (most recent call last) <ipython-input-8-e105fdffd5ff> in <cell line: 1>() ----> 1 scrapev2=scrapecomments2('https://forum.donanimhaber.com/tesla-model-y-kullananlar-kulubu-2023--155488676-1151') 1 frames /usr/local/lib/python3.10/dist-packages/selenium/webdriver/support/wait.py in until(self, method, message) 103 if time.monotonic() > end_time: 104 break --> 105 raise TimeoutException(message, screen, stacktrace) 106 107 def until_not(self, method: Callable[[D], T], message: str = "") -> Union[T, Literal[True]]: TimeoutException: Message: 但是 for comment in wait.until(EC.presence_of_all_elements_located((By.TAG_NAME,"b"))): data2.append(comment.text) 有效,因此看起来页面加载不存在问题。它返回页面中带有标签 b 的每个值,但我只想要“ki-kullaniciadi member-info”类上的值。 for comment in wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, ".ki-kullaniciadi .member-info a b")))

回答 1 投票 0

无法从 HTML 中提取文本 <td class="seats" rowspan="1"><div class='jxSeats"> ... 2 个(共 22 个)使用 BeautifulSoup 打开

我正在使用 BeautifulSoup 并且已经能够解析文档的其他部分,但无法让它识别此文本。我究竟做错了什么?这让我发疯——救命! 我正在尝试扩展...

回答 1 投票 0

<br> 标签在 React js 元素之间不起作用

在下面的代码中,标签不起作用。我正在 vscode 中工作,构建 Reactjs 应用程序。 函数主() { 返回( <> 在下面的代码中,<br>标签不起作用。我正在 vscode 中工作,构建 Reactjs 应用程序。 function Main() { return( <> <div className="d-flex justify-content-center"> <label for="height" className="text-info bg-secondary display-6" style={{marginRight: "40px",height:"50px"}}> Your Height: </label> <input type="text" id="height" placeholder="Centemeters"></input> <br /> /*This Tag is not working*/ <label className="text-info bg-secondary display-6" for="weight"> Your Weight /*this statement is showing side by side with above ones*/ </label> <input type="text" id="weight" placeholder="KG"></input> </div> </> ); } 新的使用方式<br> <br> 不起作用,你应该使用 <br />,它也适用于 hr,<hr> 不 <hr /> 代码如下: import React from 'react' const App = () => { return ( <div> {/* <br> */} <br /> </div> ) } export default App 这是您的代码: function Main() { return( <> <div className="d-flex justify-content-center"> <label for="height" className="text-info bg-secondary display-6" style={{marginRight: "40px",height:"50px"}}> Your Height: </label> <input type="text" id="height" placeholder="Centemeters"></input> <br /> <label className="text-info bg-secondary display-6" for="weight"> Your Weight /*this statement is showing side by side with above ones*/ </label> <input type="text" id="weight" placeholder="KG"></input> </div> </> ); } 那是因为你有display: flex;在容纳元素的容器上。 <div className="d-flex justify-content-center">

回答 2 投票 0

在注册表单中添加生日输入,显示在网页上,并在shopify上的客户管理中使用此数据进行过滤

我想通过在 Shopify 网站上添加生日输入来自定义注册表单,而无需任何应用程序。 然后在我的网页上显示生日数据。 然后可以重新设置生日月份的过滤功能...

回答 1 投票 0

无法正确读取 NFC 标签

每次我尝试读取 NFC 标签时,我总是会收到错误消息: if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)) 我尝试过不同的标签和 Mifare 卡,但总是遇到同样的问题....

回答 1 投票 0

基于AWS EC2标签的Puppet noop?

我们使用 puppet-enc-ec2 ENC 模块通过 AWS EC2 标签指定 puppet 节点的角色和环境。 有没有办法通过 EC2 标签强制执行 noop?另一个模块或其他东西...

回答 1 投票 0

TabView 标签和点击手势无法在 SwiftUI 中协同工作

我正在构建类似于 Instagram 故事的东西。但无论我尝试什么,选项卡视图标签或点击手势都有效。我无法让他们一起工作。目的是如果我点击左或右...

回答 1 投票 0

如何在gitlab中触发特定作业

我想在管道中运行特定作业。我认为为作业分配一个标签,然后在 post 方法中再次指定该标签就可以满足我的需求。问题是当我触发使用...

回答 3 投票 0

如何使用标签确定 Serenity bdd(黄瓜)测试执行的优先级

我有创建银行帐户的测试用例。有两种情况,一种是使用标签@logApplication提交申请,第二种是涉及的申请过程需要一些时间

回答 1 投票 0

我们应该如何使用最新的HTML标签辅助功能呢?

例如,直到 2023 年末,大多数浏览器才完全支持 标签。 所以我在等待更好的可用性和只是做之间保持平衡: ... 例如,<search>标签直到 2023 年末才在大多数浏览器上得到全面支持。 所以我在等待更好的可用性和只是做之间保持平衡: <div role="search"> ...search inputs... </div> 但我认为我们必须推广新的专用地标。 现代浏览器对未知标签非常宽容,因此在尚未实现的浏览器上使用 <search> 不会破坏任何内容。然而,它作为一个可访问的地标是没有用的。 我想过两种折衷的解决方案,但它们显然是多余的: <search> <div role="search"> ...search inputs... </div> </search> 或 <search role="search"> ...search inputs... </search> 就我而言,我需要一个相关的地标,因为我没有使用 <input type="search">,而是使用 <select>,这对于 <search> 标签规格来说非常好。 对此你有何看法? <search role="search"> 是最好的方法。 一般来说,创建有弹性、面向未来的网站的最佳方法是基于当前规范进行工作,并使用 polyfills 来弥补浏览器支持的缺乏、不一致或浏览器错误。 这就是第一个 HTML 5 元素出现时的方法。 它允许逐渐减少并最终删除填充,同时具有相当干净的代码。 谈到角色时,只需添加(根据标准)冗余角色属性即可完成polyfill。 <search>元素没有定义任何浏览器行为,因此该属性就足够了。 从其他环境中学习: <label>Registration number <input type="text" inputmode="numeric" pattern="/d+">` </label> 是在触摸屏上触发数字键盘的最佳实践。 inputmode 还没有支持,所以模式解决了它。您仍然会包含它,因为它已经标准化了。这样,网站以后就能正常运行了。 <search> <div role="search"> 不是一种选择,因为它可能会添加 2 个搜索地标,一个在另一个内。它也不符合标准。

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.