gpt4 book ai didi

javascript - 当 Blogger 帖子未托管在 Blogger 上时获取其第一个图像 URL

转载 作者:行者123 更新时间:2023-11-28 15:54:46 26 4
gpt4 key购买 nike

我使用托管服务存储我放在 Blogger 上的图片。

问题是 blogger 似乎没有获取图像 url 作为 blogger 上未上传/托管时的缩略图。

(1) 这是我用来在帖子上显示帖子的脚本。(我只是从下载模板后提供的内容中复制出来的)你可以在这里看到它的实际效果 > http://pr0x1ma1.blogspot.com/2016/12/test.html

(2) 这是包含所有外部图像的帖子 > http://pr0x1ma1.blogspot.com/2016/12/test-long.html

我怎样才能让那些外部图像出现在那些缩略图上??

(1)

var showPostDate= false,
showComments= false,
idMode = true,
sortByLabel= true,
labelSorter= "sample label",
loadingText= "Loading...",
totalPostLabel = "Total Post:",
jumpPageLabel = "Page",
commentsLabel = "Comments",
prevText= "Prev",
nextText= "Next",
postPerPage= 100,
numChars= 0,
siteUrl= "http://pr0x1ma1.blogspot.com/",
imgBlank= "http://cm3inc.com/wp-content/uploads/2016/08/npa2.jpg";
</script>
<script>
//<![CDATA[
function showPagePosts(t) {
var a, e, i, s, r, p, n, o, l = "";
0 === pagernum && (postsnum = parseInt(t.feed.openSearch$totalResults.$t), pagernum = parseInt(postsnum / postPerPage) + 1);
for(var u = 0; postPerPage > u; u++)
if("entry" in t.feed) {
if(u == t.feed.entry.length) break;
a = t.feed.entry[u], e = a.title.$t;
for(var c = 0, g = a.link.length; g > c; c++)
if("alternate" == a.link[c].rel) {
i = a.link[c].href;
break
}
for(var m = 0, d = a.link.length; d > m; m++)
if("replies" == a.link[m].rel && "text/html" == a.link[m].type) {
var v = a.link[m].title.split(" ")[0];
break
}
r = "summary" in a ? a.summary.$t.replace(/<br ?\/?>/gi, " ").replace(/<.*?>/g, "").replace(/[<>]/g, "") : "", r.length > numChars && (r = numChars >
0 && numChars !== !1 ? r.substring(0, numChars) + "..." : "");
var f = a.published.$t,
h = f.substring(0, 4),
_ = f.substring(5, 7),
b = f.substring(8, 10);
n = idMode ? ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agt", "Sep", "Okt", "Nov", "Des"] : ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
], o = showPostDate ? b + " " + n[parseInt(_, 10) - 1] + " " + h + " - " : "", p = showComments ? v + " " + commentsLabel : "", s =
"media$thumbnail" in a ? a.media$thumbnail.url.replace(/\/s\d+(\-c)?\//, "/s500-c/") : imgBlank, l += '<div class="itemposts">', l +=
'<h67><a href="' + i + '" title="' + e + '">' + e + "</a></h67>", l += '<div class="iteminside"><a href="' + i + '"><img src="' + s +
'" /></a>', l += '<span class="summary">' + r + "</span></div>", l += '<div style="clear:both;"></div><div class="itemfoot">' + o + p +
"</div>", l += "</div>"
}
_results.innerHTML = l, _create_pagination()
}

function _create_pagination() {
output = "";
var t = 0;
if(output += (actualpage > 1 ? '<a title="' + prevText + '" class="prevjson" href="javascript:_init_script(' + (actualpage - 1) + ')">' + prevText + "</a>" :
'<span class="prevjson hidden">' + prevText + "</span>") + '<em style="font:inherit;color:inherit;" class="pagernumber">', maxpage + 1 > pagernum)
for(t = 1; pagernum >= t; t++) output += t == actualpage ? '<span class="actual">' + t + "</span>" : '<a href="javascript:_init_script(' + t + ')">' +
t + "</a>";
else if(pagernum > maxpage - 1)
if(minpage > actualpage) {
for(t = 1; maxpage - 2 > t; t++) output += t == actualpage ? '<span class="actual">' + t + "</span>" : '<a href="javascript:_init_script(' + t +
')">' + t + "</a>";
output += " ... ", output += '<a href="javascript:_init_script(' + parseInt(pagernum - 1) + ')">' + parseInt(pagernum - 1) + "</a>", output +=
'<a href="javascript:_init_script(' + pagernum + ')">' + pagernum + "</a>"
} else if(pagernum - (minpage - 1) > actualpage && actualpage > minpage - 1) {
for(output += '<a href="javascript:_init_script(1)">1</a>', output += '<a href="javascript:_init_script(2)">2</a>', output += " ... ", t = actualpage -
2; actualpage + 2 >= t; t++) output += t == actualpage ? '<span class="actual">' + t + "</span>" : '<a href="javascript:_init_script(' + t + ')">' +
t + "</a>";
output += " ... ", output += '<a href="javascript:_init_script(' + (pagernum - 1) + ')">' + parseInt(pagernum - 1) + "</a>", output +=
'<a href="javascript:_init_script(' + pagernum + ')">' + pagernum + "</a>"
} else
for(output += '<a href="javascript:_init_script(1)">1</a>', output += '<a href="javascript:_init_script(2)">2</a>', output += " ... ", t = pagernum - (
minpage + 1); pagernum >= t; t++) output += t == actualpage ? '<span class="actual">' + t + "</span>" : '<a href="javascript:_init_script(' + t +
')">' + t + "</a>";
output += "</em>" + (t - 1 > actualpage ? '<a title="' + nextText + '" class="nextjson" href="javascript:_init_script(' + (actualpage + 1) + ')">' +
nextText + "</a>" : '<span class="nextjson hidden">' + nextText + "</span>"), _pagination.innerHTML = output, _totalposts.innerHTML =
totalPostLabel + " " + postsnum + " - " + jumpPageLabel + " " + (actualpage * postPerPage - (postPerPage - 1)) + (t - 1 > actualpage ? " - " +
actualpage * postPerPage : "")
}

function _init_script(t) {
var a, e, i = t * postPerPage - (postPerPage - 1),
s = document.getElementsByTagName("head")[0],
r = sortByLabel ? siteUrl + "/feeds/posts/summary/-/" + labelSorter + "?start-index=" + i : siteUrl + "/feeds/posts/summary?start-index=" + i;
1 == firstpage && (document.documentElement.scrollTop = _results.offsetTop - 30, document.body.scrollTop = _results.offsetTop - 30, a = document.getElementById(
"TEMPORAL"), a.parentNode.removeChild(a)), _results.innerHTML = '<div id="loadingscript">' + loadingText + "</div>", _pagination.innerHTML = "",
_totalposts.innerHTML = "", e = document.createElement("script"), e.type = "text/javascript", e.src = r + "&max-results=" + postPerPage +
"&orderby=published&alt=json-in-script&callback=showPagePosts", e.id = "TEMPORAL", s.appendChild(e), firstpage = 1, actualpage = t
}
var minpage = 6,
maxpage = 10,
firstpage = 0,
pagernum = 0,
postsnum = 0,
actualpage = 1;
document.write(
'<div id="toc-outer"><div id="results"></div><div id="itempager" style="position:relative;"><div id="pagination"></div><div id="totalposts"></div><a title="Taufik Nurrohman" style="display:block!important;visibility:visible!important;opacity:1!important;position:absolute;bottom:10px;right:14px;font:normal bold 8px Arial,Sans-Serif!important;color:#666;text-shadow:0 1px 0 rgba(255,255,255,.1);text-decoration:none;" href="http://hompimpaalaihumgambreng.blogspot.com/2012/03/daftar-isi-blogger-dengan-navigasi.html" target="_blank">&#9658;TN</a></div></div>'
);
var _results = document.getElementById("results"),
_pagination = document.getElementById("pagination"),
_totalposts = document.getElementById("totalposts");
window.onload = function() {
_init_script(1)
};
//]]>
</script>
<style>.comments-fb{display:none}#comments,.comments{display:none}h1.entry-title{background:#FF6B58;position:relative;padding:20px 0 30px;overflow:hidden;box-shadow:inset 0 -30px 30px -35px rgba(0,0,0,0.2);text-align:center;color:rgba(255,255,255,0.8);margin:0}h1.entry-title:after{content:"";background:url(http://4.bp.blogspot.com/-uCvqypLwH8A/VeV8F3H9CwI/AAAAAAAAElI/FgPlZg_b0D4/s1600/tp_slide.png)no-repeat center;position:absolute;left:0;width:100%;height:100%;top:0;opacity:.05}</style>

你能帮我看看怎么做吗?

最佳答案

您必须从帖子的 HTML 内容中解析它。为此,您必须将端点更改为发送请求的位置(完整提要而不是摘要版本),并处理图像未托管在 Blogger 上的情况。代码将变化如下-

<script>
//<![CDATA[
function showPagePosts(t) {
var a, e, i, s, r, p, n, o, l = "";
0 === pagernum && (postsnum = parseInt(t.feed.openSearch$totalResults.$t), pagernum = parseInt(postsnum / postPerPage) + 1);
for(var u = 0; postPerPage > u; u++)
if("entry" in t.feed) {
if(u == t.feed.entry.length) break;
a = t.feed.entry[u], e = a.title.$t;
for(var c = 0, g = a.link.length; g > c; c++)
if("alternate" == a.link[c].rel) {
i = a.link[c].href;
break
}
for(var m = 0, d = a.link.length; d > m; m++)
if("replies" == a.link[m].rel && "text/html" == a.link[m].type) {
var v = a.link[m].title.split(" ")[0];
break
}
r = "summary" in a ? a.summary.$t.replace(/<br ?\/?>/gi, " ").replace(/<.*?>/g, "").replace(/[<>]/g, "") : "", r.length > numChars && (r =
numChars >
0 && numChars !== !1 ? r.substring(0, numChars) + "..." : "");
var f = a.published.$t,
h = f.substring(0, 4),
_ = f.substring(5, 7),
b = f.substring(8, 10);
n = idMode ? ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agt", "Sep", "Okt", "Nov", "Des"] : ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
], o = showPostDate ? b + " " + n[parseInt(_, 10) - 1] + " " + h + " - " : "", p = showComments ? v + " " + commentsLabel : "", s =
"media$thumbnail" in a ? a.media$thumbnail.url.replace(/\/s\d+(\-c)?\//, "/s500-c/") : a.content.$t.match(/src\s*=\s*"([^"]+)"/) ? a.content
.$t.match(/src\s*=\s*"([^"]+)"/)[1] : imgBlank, l += '<div class="itemposts">', l +=
'<h67><a href="' + i + '" title="' + e + '">' + e + "</a></h67>", l += '<div class="iteminside"><a href="' + i + '"><img src="' + s +
'" /></a>', l += '<span class="summary">' + r + "</span></div>", l += '<div style="clear:both;"></div><div class="itemfoot">' + o + p +
"</div>", l += "</div>"
}
_results.innerHTML = l, _create_pagination()
}

function _create_pagination() {
output = "";
var t = 0;
if(output += (actualpage > 1 ? '<a title="' + prevText + '" class="prevjson" href="javascript:_init_script(' + (actualpage - 1) + ')">' + prevText +
"</a>" :
'<span class="prevjson hidden">' + prevText + "</span>") + '<em style="font:inherit;color:inherit;" class="pagernumber">', maxpage + 1 >
pagernum)
for(t = 1; pagernum >= t; t++) output += t == actualpage ? '<span class="actual">' + t + "</span>" : '<a href="javascript:_init_script(' + t +
')">' +
t + "</a>";
else if(pagernum > maxpage - 1)
if(minpage > actualpage) {
for(t = 1; maxpage - 2 > t; t++) output += t == actualpage ? '<span class="actual">' + t + "</span>" : '<a href="javascript:_init_script(' + t +
')">' + t + "</a>";
output += " ... ", output += '<a href="javascript:_init_script(' + parseInt(pagernum - 1) + ')">' + parseInt(pagernum - 1) + "</a>", output +=
'<a href="javascript:_init_script(' + pagernum + ')">' + pagernum + "</a>"
} else if(pagernum - (minpage - 1) > actualpage && actualpage > minpage - 1) {
for(output += '<a href="javascript:_init_script(1)">1</a>', output += '<a href="javascript:_init_script(2)">2</a>', output += " ... ", t =
actualpage -
2; actualpage + 2 >= t; t++) output += t == actualpage ? '<span class="actual">' + t + "</span>" : '<a href="javascript:_init_script(' + t +
')">' +
t + "</a>";
output += " ... ", output += '<a href="javascript:_init_script(' + (pagernum - 1) + ')">' + parseInt(pagernum - 1) + "</a>", output +=
'<a href="javascript:_init_script(' + pagernum + ')">' + pagernum + "</a>"
} else
for(output += '<a href="javascript:_init_script(1)">1</a>', output += '<a href="javascript:_init_script(2)">2</a>', output += " ... ", t = pagernum -
(
minpage + 1); pagernum >= t; t++) output += t == actualpage ? '<span class="actual">' + t + "</span>" : '<a href="javascript:_init_script(' +
t +
')">' + t + "</a>";
output += "</em>" + (t - 1 > actualpage ? '<a title="' + nextText + '" class="nextjson" href="javascript:_init_script(' + (actualpage + 1) + ')">' +
nextText + "</a>" : '<span class="nextjson hidden">' + nextText + "</span>"), _pagination.innerHTML = output, _totalposts.innerHTML =
totalPostLabel + " " + postsnum + " - " + jumpPageLabel + " " + (actualpage * postPerPage - (postPerPage - 1)) + (t - 1 > actualpage ? " - " +
actualpage * postPerPage : "")
}

function _init_script(t) {
var a, e, i = t * postPerPage - (postPerPage - 1),
s = document.getElementsByTagName("head")[0],
r = sortByLabel ? siteUrl + "/feeds/posts/default/-/" + labelSorter + "?start-index=" + i : siteUrl + "/feeds/posts/default?start-index=" + i;
1 == firstpage && (document.documentElement.scrollTop = _results.offsetTop - 30, document.body.scrollTop = _results.offsetTop - 30, a = document.getElementById(
"TEMPORAL"), a.parentNode.removeChild(a)), _results.innerHTML = '<div id="loadingscript">' + loadingText + "</div>", _pagination.innerHTML = "",
_totalposts.innerHTML = "", e = document.createElement("script"), e.type = "text/javascript", e.src = r + "&max-results=" + postPerPage +
"&orderby=published&alt=json-in-script&callback=showPagePosts", e.id = "TEMPORAL", s.appendChild(e), firstpage = 1, actualpage = t
}
var minpage = 6,
maxpage = 10,
firstpage = 0,
pagernum = 0,
postsnum = 0,
actualpage = 1;
document.write(
'<div id="toc-outer"><div id="results"></div><div id="itempager" style="position:relative;"><div id="pagination"></div><div id="totalposts"></div><a title="Taufik Nurrohman" style="display:block!important;visibility:visible!important;opacity:1!important;position:absolute;bottom:10px;right:14px;font:normal bold 8px Arial,Sans-Serif!important;color:#666;text-shadow:0 1px 0 rgba(255,255,255,.1);text-decoration:none;" href="http://hompimpaalaihumgambreng.blogspot.com/2012/03/daftar-isi-blogger-dengan-navigasi.html" target="_blank">&#9658;TN</a></div></div>'
);
var _results = document.getElementById("results"),
_pagination = document.getElementById("pagination"),
_totalposts = document.getElementById("totalposts");
window.onload = function() {
_init_script(1)
};
//]]>
</script>

关于javascript - 当 Blogger 帖子未托管在 Blogger 上时获取其第一个图像 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41329597/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com