Example usage for org.openqa.selenium Cookie getDomain

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

Introduction

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

Prototype

public String getDomain() 

Source Link

Usage

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. ja  v a  2s .  co  m
        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());
        c1.setPath(c.getPath());/*from  w w  w.ja  v a 2 s.  co m*/
        c1.setExpiryDate(c.getExpiry());
        store.addCookie(c1);
    }
    return store;
}