关于ERROR [us.codecraft.webmagic.Spider],如何处理空指针异常 #415

Open
dyhack opened this Issue Dec 10, 2016 · 1 comment

Projects

None yet

1 participant

@dyhack
dyhack commented Dec 10, 2016

爬取网页的时候,如果帖子不存在,就会报2016-12-10 20:13:26,926 ERROR [us.codecraft.webmagic.Spider] - process request Request{url='1.html', method='null', extras={statusCode=200}, priority=0} error
java.lang.NullPointerException

@dyhack
dyhack commented Dec 10, 2016

我要的是如何捕获异常。
2016-12-10 20:13:26,981 ERROR [us.codecraft.webmagic.Spider] - process request Request{url='1.html', method='null', extras={statusCode=200}, priority=0} error
java.lang.NullPointerException
at cn.missbe.app.webmarictest.process(HappyKorea.java:99)
at us.codecraft.webmagic.Spider.processRequest(Spider.java:420)
at us.codecraft.webmagic.Spider$1.run(Spider.java:322)
at us.codecraft.webmagic.selector.thread.CountableThreadPool$1.run(CountableThreadPool.java:74)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment