Closed zsydyc closed 8 years ago
把两处的http 换成了https就好使了
// 获取变量 var _xsrf = $("input[name='_xsrf']").attr("value"), url_token = $("#zh-question-answer-wrap").data("init").params.url_token, nodename = $("#zh-question-answer-wrap").data("init").nodename, count = $("#zh-question-answer-num").data("num"), stepCount = Math.ceil(count / 50), nowCount = 0, offset = 0;
// 新建节点,隐藏原网页 $("#zh-question-answer-wrap").empty().hide(); $("body").append('
// 主函数 loadImg(offset);
// Ajax获取资源函数 function loadImg(offset){ $.ajax({ url: 'https://www.zhihu.com/node/' + nodename, type: 'POST', dataType: 'json', data: { method: 'next', params: '{"url_token":' + url_token + ',"pagesize":50,"offset":' + offset + '}', _xsrf: _xsrf } }) .done(function(data){ for(idx in data.msg){ $("#zh-question-answer-wrap").append(data.msg[idx]); } nowCount ++; if(nowCount == stepCount){ showImg(); } else { offset += 50; loadImg(offset); }
}); } // Ajax提交已读函数 // function postRead(offset){ // var length = $(".zm-item-answer").length; // var readArr = '['; // for(var i = offset; i < length - 1; i++){ // var answerId = $(".zm-item-answer").eq(i).data("atoken"); // var readItem = '["answer",' + answerId + ', "read"],'; // readArr += readItem; // } // readArr += '["answer",' + $(".zm-item-answer").eq(length - 1).data("atoken") + ', "read"]]'; // $.ajax({ // url: 'https://www.zhihu.com/lastread/touch', // type: 'POST', // dataType: 'json', // data: { // items: readArr, // _xsrf: _xsrf // } // }) // .complete(function(data){ // nowCount ++; // if(nowCount == stepCount){ // showImg(); // } else { // offset += 50; // loadImg(offset); // } // }); // }
// 显示图像函数 function showImg(){ var length=$(".zm-item-rich-text .lazy").length, img = ""; for(var i = 0;i<length;i++){ var src = $(".zm-item-rich-text .lazy").eq(i).data("actualsrc"), people = $(".zm-item-rich-text .lazy").eq(i).parents(".zm-item-answer").find('.zm-item-link-avatar').attr("href"), peoplesrc = people ? people : src, title = people ? people : "匿名用户"; img += '
'; } $("#img-fuli").html(img); }多谢反馈,知乎现在使用了https,这个项目后续没有更新
XMLHttpRequest cannot load https://www.zhihu.com/node/QuestionAnswerListV2. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.zhihu.com' is therefore not allowed access.
@bumaociyuan 使用https://www.zhihu.com访问知乎即可,知乎这个https有点蛋疼啊,有时跳转,有时没跳转……刚刚发现知乎更新了数量限制,晚点会更新代码
@0xHJK https://gist.github.com/bumaociyuan/32dee0929c68dd8933c25a153eccb5c2 貌似知乎改版了就完全不能用了,改了一波
@bumaociyuan 好的,改了一下使用说明,多谢
error: Mixed Content: The page at 'https://www.zhihu.com/question/32680596' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.zhihu.com/node/QuestionAnswerListV2'. This request has been blocked; the content must be served over HTTPS.