php,检查文本拆分的正确性
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)个单词,下一个单词应包含其他所有单词。而主要问题是防止拆分标签(标签的描述和正文)。
<a **<=>** href="text" > text </a>
** href =“text”>文字
<a href="text" > **<=>** text </a>
** <=> **文字
<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,并通过树操作获取结果并保存数据。
更多相关文章
- PHP实现图片上添加文字(证书生成)
- 如何在页面上获得带有javascript的特定单词的链接
- 如何更改我的按钮文字?
- 获取错误“ValueError:int()的无效文字,基数为10:'3128;'在运行Tensor
- Python 用hashlib求中文字符串的MD5值
- Python自然语言处理学习笔记(3):1.1 语言计算:文本和单词
- 如何在python 3中将单词转换为数字(自己的键和值)?
- scikit-learn:在标记化时不要分隔带连字符的单词
- python的list要打印中文字符