最近在开发一个新浪新闻报道的内容抓取软件(用C#写的),像标题、时间、来源等,通过正则表达式可以精确匹配。然而,里边涉及的评论数,由于是javascript调用,无法获取,详见源码:
function cmnt_callback_2010() {
try {
var count = this.get_count();
if (count > 0) {
var show_top = document.getElementById("comment_t_show_top");
if (show_top) {
show_top.getElementsByTagName("a")[0].innerHTML = "<span class='pinglun'>已有<span class='f_c00'>" + count + "</span>条评论</span>";
}
}
}catch(e){}
} [取自http://news.sina.com.cn/h/2010-08-08/065220850016.shtml] 请问高手,如何解决? PS: 解决方案,最好可以通过C#编程语言来实现,谢谢(^_^)
function cmnt_callback_2010() {
try {
var count = this.get_count();
if (count > 0) {
var show_top = document.getElementById("comment_t_show_top");
if (show_top) {
show_top.getElementsByTagName("a")[0].innerHTML = "<span class='pinglun'>已有<span class='f_c00'>" + count + "</span>条评论</span>";
}
}
}catch(e){}
} [取自http://news.sina.com.cn/h/2010-08-08/065220850016.shtml] 请问高手,如何解决? PS: 解决方案,最好可以通过C#编程语言来实现,谢谢(^_^)
var count = this.get_count();
一条新闻报道里的评论数,是由javascript调用函数动态生成的;查看源文件只能看到变量,看不到具体的数字而我的抓取策略是先获取报道的源文件,再用正则表达式匹配
PS:辛苦你了
我猜想,他应该是有一个方法实现ajax请求到后台获取这个count的。