Example usage for org.openqa.selenium Cookie getValue

List of usage examples for org.openqa.selenium Cookie getValue

Introduction

In this page you can find the example usage for org.openqa.selenium Cookie getValue.

Prototype

public String getValue() 

Source Link

Usage

From source file:zz.pseas.ghost.login.jd.JDCookie.java

License:Apache License

public CookieStore supplyCookies() {
    if (!(paramDone && cookieDone)) {
        return null;
    }//from  www .  j  a  v  a  2s. c  o m

    BasicCookieStore cookieStore = new BasicCookieStore();
    Set<Cookie> cookies = browser.manage().getCookies();
    for (Cookie c : cookies) {
        BasicClientCookie c1 = new BasicClientCookie(c.getName(), c.getValue());
        /*
        c1.setDomain(c.getDomain());
        c1.setPath(c.getPath());
        */
        c1.setExpiryDate(c.getExpiry());
        cookieStore.addCookie(c1);
    }
    return cookieStore;
}

From source file:zz.pseas.ghost.login.weibo.WeiboLogin.java

License:Apache License

public static void main(String[] args) {
    WebDriver driver = BrowserFactory.getIE();

    driver.get("http://weibo.com/");

    Set<Cookie> cookies = driver.manage().getCookies();
    BasicCookieStore cookieStore = new BasicCookieStore();
    for (Cookie c : cookies) {
        BasicClientCookie c1 = new BasicClientCookie(c.getName(), c.getValue());
        c1.setDomain(c.getDomain() == null ? "weibo" : c.getDomain());
        c1.setPath(c.getPath());//from  w  w w  .j a  va 2s .  c  om
        Date d = c.getExpiry();
        if (d != null) {
            c1.setExpiryDate(d);
        }
        cookieStore.addCookie(c1);
    }
    driver.quit();

    GhostClient client = new GhostClient("utf-8", cookieStore);
    String url = "http://weibo.com/p/10080813dc27e2acb1441006674c8aa2ef07d4/followlist?page=1#Pl_Core_F4RightUserList__38";
    //HttpGet get = new HttpGet(url);
    String s = client.get(url);
    System.out.println(s);
    String next = StringUtil.regex(s, "(?<=replace\\(\").*?(?=\")");
    String html = client.get(next);
    System.out.println(html);
}

From source file:zz.pseas.ghost.utils.DownloadUtil.java

License:Apache License

public static CookieStore convertToCookieStore(Set<Cookie> cookies) {
    BasicCookieStore store = new BasicCookieStore();
    for (Cookie c : cookies) {
        BasicClientCookie c1 = new BasicClientCookie(c.getName(), c.getValue());
        c1.setDomain(c.getDomain());/*w  w  w. j  ava  2 s  . c  om*/
        c1.setPath(c.getPath());
        c1.setExpiryDate(c.getExpiry());
        store.addCookie(c1);
    }
    return store;
}