Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mylasttest;
- import java.io.IOException;
- import java.net.MalformedURLException;
- import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
- import com.gargoylesoftware.htmlunit.Page;
- import com.gargoylesoftware.htmlunit.WebClient;
- import com.gargoylesoftware.htmlunit.html.HtmlForm;
- import com.gargoylesoftware.htmlunit.html.HtmlPage;
- import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
- import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
- public class mylasttest {
- public static void main(String[] args) throws FailingHttpStatusCodeException, MalformedURLException, IOException {
- final WebClient webClient = new WebClient();
- final HtmlPage page = (HtmlPage) webClient.getPage("http://pastebin.com/login");
- final HtmlForm form = page.getFormByName("myform");
- final HtmlTextInput user_name = (HtmlTextInput) form.getInputByName("user_name");
- final HtmlTextInput user_password = (HtmlTextInput) form.getInputByName("user_password");
- final HtmlSubmitInput button = (HtmlSubmitInput) form.getInputByName("submit");
- user_name.setValueAttribute("ton_nomdecompte");
- user_password.setValueAttribute("ton_mdp");
- final HtmlPage result_page = (HtmlPage) button.click();
- webClient.closeAllWindows();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement