如何从网页中直接获取投票结果? 如果就以这个新闻链接为例子,我想获取心情投票的结果,该如何做呢?http://www.chinanews.com.cn/gn/news/2009/03-17/1606008.shtml 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用jquery给你写个例子吧L@_@K<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title> <script type="text/javascript" src="js/jq.js"></script> <script type="text/javascript"> function alertdata(data) { var temp= data; alert(temp); } $.ajax({ type: "get", url: "http://www.cnblogs.com/rss", beforeSend: function(XMLHttpRequest){ //ShowLoading(); }, success: function(data, textStatus){ alertdata(data); $(".ajax.ajaxResult").html(""); $("item",data).each(function(i, domEle){ $(".ajax.ajaxResult").append("<li>"+$(domEle).children("title").text()+"</li>"); }); }, complete: function(XMLHttpRequest, textStatus){ //HideLoading(); }, error: function(){ //请求出错处理 }}); </script></head><body> <form id="form1" runat="server"> <div id="roteResult"> <p class="ajax ajaxResult"> </p> </div> </form></body></html> 一个经常要用到 ajax 的地方!其它的不用说了!~ require 'net/http'require 'iconv'http=Net::HTTP.new 'mood.chinanews.com.cn' #事实上的投票后会重新访问服务器res,data=http.get '/data/2009/03/17/1606008.shtml' #从此对应地址取得投票结果v=data.scan(/\t(\d+)/) #然后正则分析,得到投票结果s=data.scan /<td width="70" height="20" align="center">(.*)</ #和对应的选项#打印投票结果 ,将gbk转为utf8输出v.each_index {|i| print Iconv.conv('utf8','GBK',s[i][0]),':',v[i][0],"\r\n"} file上传文件控件 javascript如何做条件判断。简单初级问题。突然转不过来。。。 JavaScript运行时错误, this.el.dom为空或错误 向各位请教一个问题 js写cookie总出问题 jquery可编辑表格 从网页上DOWN个日历HTML代码 JS高手看看吧,右键菜单中传递对象名的问题? 请问用javascript如何去除本窗口的地址栏,工具拦等? 如何把object对象作为参数代入js函数中呢? Warning: Cannot modify header information ,谢谢 一个关于select元素的JavaScript
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" src="js/jq.js"></script>
<script type="text/javascript">
function alertdata(data)
{
var temp= data;
alert(temp);
}
$.ajax({
type: "get",
url: "http://www.cnblogs.com/rss",
beforeSend: function(XMLHttpRequest){
//ShowLoading();
},
success: function(data, textStatus){
alertdata(data);
$(".ajax.ajaxResult").html("");
$("item",data).each(function(i, domEle){
$(".ajax.ajaxResult").append("<li>"+$(domEle).children("title").text()+"</li>");
});
},
complete: function(XMLHttpRequest, textStatus){
//HideLoading();
},
error: function(){
//请求出错处理
}
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="roteResult">
<p class="ajax ajaxResult">
</p>
</div>
</form>
</body>
</html>
一个经常要用到 ajax 的地方!其它的不用说了!~
require 'iconv'
http=Net::HTTP.new 'mood.chinanews.com.cn' #事实上的投票后会重新访问服务器
res,data=http.get '/data/2009/03/17/1606008.shtml' #从此对应地址取得投票结果v=data.scan(/\t(\d+)/) #然后正则分析,得到投票结果
s=data.scan /<td width="70" height="20" align="center">(.*)</ #和对应的选项
#打印投票结果 ,将gbk转为utf8输出
v.each_index {|i| print Iconv.conv('utf8','GBK',s[i][0]),':',v[i][0],"\r\n"}