I need to split html document on two parts. First part, should contain N(30) words, and next one should contain everything else. And the main problem, is to prevent splitting tags (description and body of tags).

我需要将html文档拆分为两部分。第一部分,应包含N(30)个单词,下一个单词应包含其他所有单词。而主要问题是防止拆分标签(标签的描述和正文)。

  1. <a **<=>** href="text" > text </a>

    ** href =“text”>文字

  2. <a href="text" > **<=>** text </a>

    ** <=> **文字

  3. <a href="text" > text </ **<=>** a>

    text ** a>

Give me please suggestions (or if you have already written such function, please share your code), how to realize it! Thanks.

请给我建议(或者如果你已经写过这样的功能,请分享你的代码),如何实现它!谢谢。

1 个解决方案

#1


1

Use DOM Parser, documentation you can find at http://php.net/manual/en/book.dom.php

使用DOM Parser,您可以在http://php.net/manual/en/book.dom.php找到该文档

You can parse your html in a tree with this class, and get your result by tree manipulation and saving your data.

您可以使用此类在树中解析html,并通过树操作获取结果并保存数据。

更多相关文章

  1. PHP实现图片上添加文字(证书生成)
  2. 如何在页面上获得带有javascript的特定单词的链接
  3. 如何更改我的按钮文字?
  4. 获取错误“ValueError:int()的无效文字,基数为10:'3128;'在运行Tensor
  5. Python 用hashlib求中文字符串的MD5值
  6. Python自然语言处理学习笔记(3):1.1 语言计算:文本和单词
  7. 如何在python 3中将单词转换为数字(自己的键和值)?
  8. scikit-learn:在标记化时不要分隔带连字符的单词
  9. python的list要打印中文字符

随机推荐

  1. IOS学习之WebView加载本地HTML代码或网络
  2. 利用HTML canvas制作酷炫星星坠地粒子特
  3. html5: 新特性(表单)
  4. CHtmlEditCtrl (3): More HTML Editor Op
  5. JQuery函数不能用于初始触发器
  6. 百度地图Api进阶教程-实例高级操作8.html
  7. HTML5新增标签与属性
  8. 如何确定在web页面上呈现的字符串的长度(
  9. telnet建立http连接获取网页HTML内容
  10. jQuery:流体同位素仅在调整大小后才工作