java - Login & Extract Data from a webpage Jsoup -
so trying logon website , element off other webpages within website "http://www.website.com"
public class ticketingjsoup { public static void main (string [] args) throws ioexception{ try { string url = "www.website.com"; connection.response response = jsoup.connect(url).method(connection.method.get).execute(); response = jsoup.connect(url) .cookies(response.cookies()) .data("action", "login") .data("user", "myuser") .data("password", "mypass") .method(connection.method.post) .followredirects(true) .execute(); document document = response.parse(); system.out.println(document); map<string, string> logincookies = response.cookies(); elements ticketnumber = doc.select("body > div.mainbox.ariarolemain.usearticlecolors > div.headline > h1"); system.out.println(ticketnumber); system.out.println("test"); } catch (ioexception e) { e.printstacktrace(); } }
}
stack trace
java.net.sockettimeoutexception: read timed out @ java.net.socketinputstream.socketread0(native method) @ java.net.socketinputstream.socketread(unknown source) @ java.net.socketinputstream.read(unknown source) @ java.net.socketinputstream.read(unknown source) @ java.io.bufferedinputstream.fill(unknown source) @ java.io.bufferedinputstream.read1(unknown source) @ java.io.bufferedinputstream.read(unknown source) @ sun.net.www.http.httpclient.parsehttpheader(unknown source) @ sun.net.www.http.httpclient.parsehttp(unknown source) @ sun.net.www.protocol.http.httpurlconnection.getinputstream0(unknown source) @ sun.net.www.protocol.http.httpurlconnection.getinputstream(unknown source) @ java.net.httpurlconnection.getresponsecode(unknown source) @ org.jsoup.helper.httpconnection$response.execute(httpconnection.java:516) @ org.jsoup.helper.httpconnection$response.execute(httpconnection.java:534) @ org.jsoup.helper.httpconnection$response.execute(httpconnection.java:493) @ org.jsoup.helper.httpconnection.execute(httpconnection.java:205) @ ticketingjsoup.main(ticketingjsoup.java:25)
what doing wrong? i'm racking brain trying figure out how this, ive tried many other things lead dead end. think best way if mistake please show me better way.
thanks.
try code:
try { string url = "www.website.com"; connection.response response = jsoup.connect(url).method(connection.method.get).execute(); response = jsoup.connect(url) .cookies(response.cookies()) .data("action", "login") .data("user", "your_login") .data("password", "your_password") .method(connection.method.post) .followredirects(true) .execute(); document document = response.parse(); system.out.println(document); } catch (ioexception e) { e.printstacktrace(); }
Comments
Post a Comment