import re html = ''' <html> <meta http-equiv="Content=-Type" content="text/html; charset=utf-8"/> <head> <link href="http://192.167.1.101/hint.css" rel="stylesheet"></link> </head> <body>[talkid:137031381]2014年4月20日 03:55:45 , <span class="hint-success" data-hint="">2323234</span> 在群 <span class="hint-success" data-hint="">20011</span> 中发言 我们已经是dffwerwer天吧! [talkid:137031382]2014年4月22日 04:45:45 , <span class="hint-success" data-hint="">2323234</span> 在群 <span class="hint-success" data-hint="">20011</span> 中发言 音频 :[<a href="files/24434sfsfsjdfrhf_n.m4a"]>音频</a> [talkid:137031383]2014年4月23日 04:55:45 , <span class="hint-success" data-hint="">2323234</span> 在群 <span class="hint-success" data-hint="">20011</span> 中发言 图片 :[<a href="files/f/f123ftrtrhf_n.jpg"]>图片</a> [talkid:137031384]2014年4月24日 05:55:45 , <span class="hint-success" data-hint="">2323234</span> 在群 <span class="hint-success" data-hint="">20011</span> 中发言 我们已方式方法方式 [talkid:137031385]2014年4月25日 06:55:45 , <span class="hint-success" data-hint="">2323234</span> 在群 <span class="hint-success" data-hint="">20011</span> 中发言 我而对方是否的天吧! </body> </html> ''' pattern = r'\(发送|中发言)\s*(.*?).*?(音频 :|图片 :).*?(\[.*?\])' matches = re.findall(pattern, html, re.DOTALL) for match in matches: content= match[0] content_type = match[1] file_link = match[2] if content_type == '音频 :': print(f"音频链接地址: {file_link}") elif content_type == '图片 :': print(f"图片链接地址: {file_link}") else: print(f"发言字段: {content}")
时间: 2023-10-17 09:05:19 浏览: 47
您稍作修改的代码是正确的,可以提取到发言字段以及音频和图片链接地址。输出结果如下:
```
发言字段: 2014年4月20日 03:55:45 , 2323234 在群 20011 中发言 我们已经是dffwerwer天吧!
音频链接地址: [files/24434sfsfsjdfrhf_n.m4a]
图片链接地址: [files/f/f123ftrtrhf_n.jpg]
发言字段: 2014年4月24日 05:55:45 , 2323234 在群 20011 中发言 我们已方式方法方式
发言字段: 2014年4月25日 06:55:45 , 2323234 在群 20011 中发言 我而对方是否的天吧!
```
这样您就可以得到所需的发言字段和音频、图片文件的链接地址。
相关问题
详细解读一下这段代码:<%@ page language="java" import="java.text.*,java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>使用application内置对象--inputMessage.jsp</title> <style> #form2 input { color: green; font-weight: bold; } </style> </head> <body bgcolor="#abcdef"> <form action="checkMessage.jsp" method="post"> 请输入姓名: <input type="text" name="name" /><br> 请输入标题: <input type="text" name="title" /><br> 请输入内容: <textarea cols="40" rows="10" name="message"></textarea> <br> <br> <br> <input type="submit" value="留言" /> </form> <br> <form id="form2" action="showMessage.jsp" method="post"> <input type="submit" value="查看留言板" /> </form> </body> </html>
这是一个JSP页面,用于实现留言板功能。下面是对每部分的解释:
1. <%@ page ... %>:这是指令部分,用于定义该JSP页面的属性,例如语言,字符集等。
2. <html> ... </html>:这是HTML标签部分,用于定义网页的结构和内容。
3. <head> ... </head>:这是头部标签部分,用于定义网页的标题、字符集等信息。
4. <meta>:该标签用于设置网页的元数据,例如字符集、关键字等。
5. <title>:该标签用于设置网页的标题。
6. <style> ... </style>:该标签用于定义网页的样式,例如文本颜色、字体等。
7. <body> ... </body>:该标签用于定义网页的主体部分。
8. <form> ... </form>:该标签用于定义一个表单,用于用户输入和提交数据。
9. <input>:该标签用于定义表单中的输入框,例如文本框、单选框等。
10. <textarea>:该标签用于定义表单中的多行文本框。
11. <br>:该标签用于定义换行符。
12. <submit>:该标签用于定义表单中的提交按钮。
总体来说,该JSP页面包含两个表单,一个用于输入留言信息,另一个用于查看留言板。用户在输入留言信息的表单中,需要输入姓名、标题和内容,并点击“留言”按钮提交信息到checkMessage.jsp页面进行验证和保存。在查看留言板的表单中,用户可以点击“查看留言板”按钮跳转到showMessage.jsp页面查看留言信息。
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <link rel="icon" href="<%= BASE_URL %>favicon.ico"> <title><%= webpackConfig.name %></title> </head> <body> <noscript> <strong>We're sorry but <%= webpackConfig.name %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> </noscript> <div id="app"></div> <!-- built files will be auto injected --> </body> </html>怎么国际化处理name
要对网页标题进行国际化处理,可以使用前端框架或库提供的国际化功能。根据提供的 HTML 代码,看起来你正在使用 Vue.js 或者类似的前端框架。
在 Vue.js 中,可以使用插件 vue-i18n 来实现国际化。首先,需要在项目中安装 vue-i18n 插件。可以通过 npm 或者 yarn 进行安装:
```
npm install vue-i18n
```
安装完成后,在项目的主入口文件(例如 main.js)中引入并初始化 vue-i18n:
```javascript
import Vue from 'vue';
import VueI18n from 'vue-i18n';
Vue.use(VueI18n);
const i18n = new VueI18n({
locale: 'en', // 默认语言
messages: {
en: { // 英文语言包
title: 'Your Website Name',
// 其他国际化文本
},
zh: { // 中文语言包
title: '你的网站名字',
// 其他国际化文本
}
}
});
new Vue({
i18n,
render: h => h(App)
}).$mount('#app');
```
在上述代码中,我们定义了两个语言包:英文(en)和中文(zh),每个语言包中都定义了对应的网页标题(title)。
然后,在 HTML 代码中使用国际化的标题:
```html
<title>{{ $t('title') }}</title>
```
`$t` 是 vue-i18n 提供的翻译函数,它会根据当前语言环境选择对应的翻译文本。通过这种方式,可以根据用户的语言环境切换网页标题。
当然,这只是一个简单示例,实际的国际化处理可能需要更复杂的配置和多语言支持。你可以参考 vue-i18n 的官方文档来进一步了解如何进行国际化处理。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="com.test.bean.Goods,java.util.ArrayList" %> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>购物车</title> <style type="text/css"> table{border-collapse:collapse;} td{border:1px solid black; text-align:center; } #deal{margin-left:200px} </style> </head> <body> <jsp:useBean id="cart" class="com.test.bean.Cart" scope="session"></jsp:useBean> <%if(cart==null||cart.getGoodslist().size()==0) out.println("购物车空空如也.....返回商品首页"); else{ ArrayList<Goods>goodslist=cart.getGoodslist(); %> 当前购物车共有<%=cart.getGcount() %>件物品 返回商品首页
序号 商品号 商品名称 价格 数量 小计 描述 <%for(int i=0;i<goodslist.size();i++){ Goods goods=goodslist.get(i); %> <%=i+1 %> <%=goods.getGid() %> <%=goods.getGname() %> <%= String.format("%.2f", goods.getGprice())%> <%=goods.getGcount() %> <%=String.format("%.2f", goods.getGprice()*goods.getGcount()) %> 删除 <%}%>
总计<%=String.format("%.2f",cart.getTotal())%> <input type="button" id="deal" value="购买" /></input> <%}%> <script type="text/javascript"> var dealbutton=document.getElementById("deal"); dealbutton.onclick=function(){ var cf=confirm("确定购买吗?"); if(cf==true){ window.location.href="Servlet/DealServlet"; } } </script> </body> </html> 修改删除功能,在购物车物品数量大于1的情况下点击“删除”时减少1个,等于1时删除此项商品;
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
网页源代码模板如下: <html> <meta http-equiv="Content=-Type" content="text/html; charset=utf-8"/> <head> </head> <body>[talkid:137031381]2014年4月20日 03:55:45 , 2323234 在群 20011 中发言 我们已经是dffwerwer天吧! () [talkid:137031382]2014年4月22日 04:45:45 , 2323234 在群 20011 中发言 音频 :[音频 () [talkid:137031383]2014年4月23日 04:55:45 , 2323234 在群 20011 中发言 图片 :[图片 () [talkid:137031384]2014年4月24日 05:55:45 , 2323234 在群 20011 中发言 我们已方式方法方式 () [talkid:137031385]2014年4月25日 06:55:45 , 2323234 在群 20011 中发言 我而对方是否的天吧! () </body> </html> 利用python爬虫,提取源代码字符串,并从每行body中爬取[<a href=后的文件名称,如果没有则将该行文件名设置为NONE
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
<html> <meta http-equiv="Content=-Type" content="text/html; charset=utf-8"> <head> </head> <body>[talkid:138031361]204年4月20日 03:55:45 , 434343 向 232323 发送 我们已经是好友了,开始聊天吧! () [talkid:138031362]204年4月20日 04:45:45 , 434343 向 123456 发送 音频 :[<ahref="files/f/f123fsasfsfsjdfrhf_n.m4a"]>音频
() [talkid:138031363]204年4月20日 04:55:45 , 434343 向 123456 发送 音频 :[<ahref="files/f/f123fsasfsfsjdfrhf_n.jpg"]>图片 () [talkid:138031364]204年4月20日 05:55:45 , 434343 向 3234221 发送 我们已经是好友了,开始聊天吧! () [talkid:138031365]204年4月20日 06:55:45 , 434343 向 1359075 发送 我们已经是好友了,开始聊天吧! () </body> </html>提取网页内ID、时间、发送号码、接收号码、信息内容,如果是音频则提取文件地址![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>人力资源管理系统</title> <meta http-equiv="Content-Type" content="text/html; charset=GBK"> </head> <body> 人才信息 姓名 性别 年龄 职位 所学专业 工作经验 执行操作 we33 男 0 ew we ew 详细 删除 ds 女 0 ds ds ds 详细 删除 李四 男 36 JAVA架构师 计算机 5年 详细 删除 王五 男 28 软件测试工程师 计算机 三年 详细 删除 </body> </html>实现后端代码
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)