通过网页搜索
嘿,我正在开发一个 Python 项目,需要浏览网页。我想查找特定的文本,如果找到该文本,则会打印出一些内容。如果没有,它会打印出一条错误消息。我已经尝试过不同的模块,例如 libxml,但我不知道该怎么做。
有人可以提供帮助吗?
Hey I'm working on a Python project that requires I look through a webpage. I want to look through to find a specific text and if it finds the text, then it prints something out. If not, it prints out an error message. I've already tried with different modules such as libxml but I can't figure out how I would do it.
Could anybody lend some help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以做一些简单的事情,比如:
You could do something simple like:
lxml 很棒: http://lxml.de/parsing.html
我经常将它与 xpath 一起使用来提取来自 html 的数据。
另一个选项是 http://www.crummy.com/software/BeautifulSoup/ 这是也很棒。
lxml is awesome: http://lxml.de/parsing.html
I use it regularly with xpath for extracting data from the html.
The other option is http://www.crummy.com/software/BeautifulSoup/ which is great as well.