The JSoup website is down, so does anyone feel like helping me?
Trying to do the Gaia Login in Java. I was thinking of using JSoup to fetch all of the names of the inputs, and then fetch the values so that I could then submit them with the username and password to login. I can't figure out how to fetch the name of a randomly-named field though, but it seems like there's some next() thing I could use. I can't be sure though, because I can't check on the JSoup website because it's down.
I already have the username and password submit set up:
Code:
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class Login
{
public static void main(String[] args) throws UnsupportedEncodingException
{
String lookfor = "from your Gaia account";
String postData = "username=" + URLEncoder.encode("userhere", "UTF-8") +
"&password=" + URLEncoder.encode("passhere", "UTF-8");
HTTPRequest request = new HTTPRequest();
request.setURL("http://www.gaiaonline.com.com");
System.out.println("Request: " + request);
System.out.println("URL: " + request.getURL());
System.out.println("Get: " + request.get());
System.out.println("Post: " + request.post("/auth/login", postData));
System.out.println("Get: " + request.get());
int index1 = request.get().indexOf(lookfor);
if (index1 != -1)
{
System.out.println("Login Success");
}
else
{
System.out.println("Login Failed");
}
}
}
But I need to use JSoup to grab the SID and Token and randomly generated input and then submit those too.
I had this as code to try to grab SID a few months ago, but I forget how it worked and it's not producing any output lol:
Code:
import org.jsoup.Jsoup;
import org.jsoup.helper.Validate;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
class JSoupTest {
public static void main(String[] args) throws IOException {
Document doc = Jsoup.connect("http://gaiaonline.com/auth/login").get();
Elements inputs = doc.select("sid");
for(Element input : inputs) {
System.out.println(input.attr("name"));
System.out.println(input.attr("value"));
}
}
}
And I can't check my code and see what it does or anything, because the JSoup website is down.
Anyway, thanks.