获取html文件Java [英] Get html file Java

查看:199
本文介绍了获取html文件Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


如何以编程方式下载Java网页?

如何在Java中获取html

我正在开发一个包含以下内容的应用程序:用户输入某个网站的URL,然后应用程序必须分析该URL。

I'm developping an application that consists on: the user inputs an URL of some website, and then the application have to analyze that URL.

如何我可以使用Java访问HTML文件吗?我需要使用HttpRequest吗?
如何运作?

How can I have access to the HTML file, using Java? Does I need to use HttpRequest? How does that works?

Thks。

推荐答案

对于简单的情况,URLConnection很好。如果涉及到重定向等问题,最好使用Apache的 HTTPClient

URLConnection is fine for simple cases. When there are things like redirections involved, you are better off using Apache's HTTPClient

这篇关于获取html文件Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆