youku上面超过100拆分多个列表展示,全部是js生成的。
上面代码执行的成功率不是很高。
2013.12.05 19:25:58 Re-synchronized call to ?__rt=1&__ro=listitem_page2
2013.12.05 19:26:00 Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded JavaScript element at 'http://html.atm.youku.com/html?p=74,75,558,747,753,850,101618,616,101564&ct=h&cs=2224|2210|2209&td=0&s=271942&v=119023280&u=83980375&k=%E7%BD%91%E7%90%83%E7%8E%8B%E5%AD%90|&sid=1386242750138i0r&tt=网球王子 001&pu=http://v.youku.com/v_show/id_XNDc2MDkzMTIw.html&ref=', but got 'text/html'.
其实只要能拿到Re-synchronized call to后面的URL后直接使用httpclient就可以了。但是htmlunit没有提供相关方法。debug了一下源码还是没找到什么时候这个URL被生成的(这个URL肯定是js函数中生成并异步调用的)。
继续研究。。。
第二种方法是使用selenium,jdic直接调用浏览器。htmlunit
这两种方式都太慢。相对来说第一种方式效率比第二种要好一些。
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-38449-2.html
建造年代早就是老旧军舰