Commit ff2f588c authored by yihua.huang's avatar yihua.huang

#48 nullpointer exception

parent ac516f9b
......@@ -47,8 +47,7 @@ public class HttpClientDownloader implements Downloader {
* @return html
*/
public Html download(String url) {
Page page = download(new Request(url), null);
return (Html) page.getHtml();
return download(url, null);
}
/**
......
......@@ -6,6 +6,7 @@ import org.junit.Test;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Request;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.selector.Html;
/**
* Author: code4crafer@gmail.com
......@@ -23,4 +24,11 @@ public class HttpClientDownloaderTest {
Assert.assertTrue(download.getHtml().toString().contains("flashsword30"));
}
@Test
public void testDownloader() {
HttpClientDownloader httpClientDownloader = new HttpClientDownloader();
Html html = httpClientDownloader.download("http://www.oschina.net");
Assert.assertTrue(!html.getText().isEmpty());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment