我正在使用 java 并尝试获取网站的内容,以便我可以分析页面上的文本,但是每次我“获取”来自服务器的响应时,它来自登录页面而不是网站页面我正在看。
我在所有浏览器上都登录了该网站,但我的应用程序无法像看到我一样看到该页面。
我还尝试使用名为“Yandex”的 API --> http://api.yandex.com/rca/ 作为解决方法。但是当我从 Yandex 调用该页面(这将获取其内容)时,我只能看到基于返回的登录页面的信息。
谁能给我一个调查的方向?我希望能够在我工作的网站页面上获得一个项目,但这似乎不可能。
m_strseedpath = "http://myUrl.com/mypage.html"; //not https
URLConnection connection = new URL("http://rca.yandex.com/?key={MyActualKeyNotThisText}&url=" + m_strSeedUrlPath + "").openConnection();
connection.setRequestProperty("Accept-Charset", "UTF-8");
InputStream response = connection.getInputStream();
StringWriter writer = new StringWriter();
IOUtils.copy(response, writer, "UTF-8");
String strString = writer.toString();
System.out.println(strString);