Java服务器重定向次数过多。需要帮助确定新的URL吗
我正在开发一个连接到okcupid.com并使用有效用户名和密码登录的应用程序。在测试期间,我让它运行良好,但最近okc服务器端一定发生了一些变化,因为我收到一个错误,表明服务器重定向了太多次(2)(请参阅下面的错误输出) 直到最近,使用的代码Java服务器重定向次数过多。需要帮助确定新的URL吗,java,httpurlconnection,Java,Httpurlconnection,我正在开发一个连接到okcupid.com并使用有效用户名和密码登录的应用程序。在测试期间,我让它运行良好,但最近okc服务器端一定发生了一些变化,因为我收到一个错误,表明服务器重定向了太多次(2)(请参阅下面的错误输出) 直到最近,使用的代码(http://www.okcupid.com/locquery?func=query&query=“+zip)如果我访问此URL或使用下面的学习循环发布的代码,我仍然可以获得输出,但我的应用程序(使用帐户登录)停止工作。我认为cookie发生了一些变化。
(http://www.okcupid.com/locquery?func=query&query=“+zip)
如果我访问此URL或使用下面的学习循环发布的代码,我仍然可以获得输出,但我的应用程序(使用帐户登录)停止工作。我认为cookie发生了一些变化。大多数错误消息都会返回到位置ID。有人能解释一下如何在登录t时使用Chrome或Firefox来精确定位此URL吗o通过浏览器进行okc,以便我可以对代码进行适当的更改?提前感谢
java.net.ProtocolException: Server redirected too many times (20)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1469)
at okc.jurl.run(jurl.java:149)
at java.lang.Thread.run(Thread.java:695)
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 1
at okc.Utils.find(Utils.java:60)
at okc.LocationAssistant.findLocid(LocationAssistant.java:125)
at okc.AccountManager.findLocid(AccountManager.java:390)
at okc.OkcView.getLocid(OkcView.java:3088)
at okc.OkcView.login(OkcView.java:2924)
at okc.OkcView.access$20(OkcView.java:2912)
at okc.OkcView$15.actionPerformed(OkcView.java:1114)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6414)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3275)
at java.awt.Component.processEvent(Component.java:6179)
at java.awt.Container.processEvent(Container.java:2084)
at java.awt.Component.dispatchEventImpl(Component.java:4776)
at java.awt.Container.dispatchEventImpl(Container.java:2142)
at java.awt.Component.dispatchEvent(Component.java:4604)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4279)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4209)
at java.awt.Container.dispatchEventImpl(Container.java:2128)
at java.awt.Window.dispatchEventImpl(Window.java:2492)
at java.awt.Component.dispatchEvent(Component.java:4604)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:717)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:676)
at java.awt.EventQueue$2.run(EventQueue.java:674)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:690)
at java.awt.EventQueue$3.run(EventQueue.java:688)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:687)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
获取值的URL似乎缺少
func
关键字
例如,以下URL有效:
https://www.okcupid.com/locquery?func=query&query=14850
{"status" : 0, "ZipCode" : "14850", "query" : "14850", "locid" : 4333788,
"results" : [{"locid" : 4333788, "text" : "Ithaca"}]}
其中,以下各项没有:
https://www.okcupid.com/locquery?=query&query=14850
{"query" : ""}
主要检查您的代理设置是否有任何更改。以下程序使用正确的代理设置
import java.net.*;
import java.io.*;
public class URLReader {
public static void main(String[] args) throws Exception {
//Following line needs to be enabled accordingly if you are using proxy
//If you are enabling proxy, replace proxy.com with your proxy address
//System.setProperty("https.proxyHost", "proxy.com");
//System.setProperty("https.proxyPort", "80");
URL oracle =
new URL("https://www.okcupid.com/locquery?func=query&query=14850");
BufferedReader in = new BufferedReader(
new InputStreamReader(oracle.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
事实上,我的代码中有func。我在写文章时不小心漏掉了它。我已经编辑并更新了。如果有任何帮助,我们将不胜感激。@DBD现在答案已更新。您可以尝试使用代理设置并使用https而不是https。谢谢。我回家后会看一看。如果我需要,是否可以通过messenger或电子邮件与您联系ed进一步的帮助?最终我会在这里发布,确认它是否有效,并给你评分。好的。我想我需要澄清一点。这篇文章的输出基本上只是显示了如果我将URL粘贴到浏览器中,我会得到什么。我已经知道这个链接是有效的。我在运行我的应用程序时遇到了问题,它会将我的帐户登录到occulated.com,但它一直在运行以前工作过。他们用他们的登录cookie更改了一些东西,我确定,但我不知道如何修复它。你能发布一个程序来演示如何使用有效帐户登录吗?我将更新原始版本以澄清。