Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
RSS JSON显示的Javascript函数未获得正确的配置文件图片_Javascript_Json_Rss - Fatal编程技术网

RSS JSON显示的Javascript函数未获得正确的配置文件图片

RSS JSON显示的Javascript函数未获得正确的配置文件图片,javascript,json,rss,Javascript,Json,Rss,我想使用此javascript函数获取此站点()每篇文章的个人资料照片,但我没有得到正确的照片。请指导我更改代码以获得合适的照片。非常感谢。这是代码 $(function () { var $content = $('#jsonContent'); var data = { rss_url: 'https://medium.com/feed/@femalefounderssg' }; $.get('https://api.rss2json.com/v1/api.json', data,

我想使用此javascript函数获取此站点()每篇文章的个人资料照片,但我没有得到正确的照片。请指导我更改代码以获得合适的照片。非常感谢。这是代码

$(function () {
var $content = $('#jsonContent');
var data = {
    rss_url: 'https://medium.com/feed/@femalefounderssg'
};
$.get('https://api.rss2json.com/v1/api.json', data, function (response) {
    if (response.status == 'ok') {
        var output = '';
        $.each(response.items, function (k, item) {
            var visibleSm;
            if(k < 3){
                visibleSm = '';
             } else {
                 visibleSm = ' visible-sm';
             }
            output += '<div class="col-sm-6 col-md-4' + visibleSm + '">';
            output += '<div class="blog-post"><header>';
            output += '<h4 class="date">' + $.format.date(item.pubDate, "dd<br>MMM") + "</h4>";
            var tagIndex = item.description.indexOf('<img'); // Find where the img tag starts
            var srcIndex = item.description.substring(tagIndex).indexOf('src=') + tagIndex; // Find where the src attribute starts
            var srcStart = srcIndex + 5; // Find where the actual image URL starts; 5 for the length of 'src="'
            var srcEnd = item.description.substring(srcStart).indexOf('"') + srcStart; // Find where the URL ends
            var src = item.description.substring(srcStart, srcEnd); // Extract just the URL
            output += '<div class="blog-element"><img class="img-responsive" src="' + src + '" width="360px" height="240px"></div></header>';
            output += '<div class="blog-content"><h4><a href="'+ item.link + '">' + item.title + '</a></h4>';
            output += '<div class="post-meta"><span>By ' + item.author + '</span></div>';
            var yourString = item.description.replace(/<img[^>]*>/g,""); //replace with your string.
            var maxLength = 120 // maximum number of characters to extract
            //trim the string to the maximum length
            var trimmedString = yourString.substr(0, maxLength);
            //re-trim if we are in the middle of a word
            trimmedString = trimmedString.substr(0, Math.min(trimmedString.length, trimmedString.lastIndexOf(" ")))
            output += '<p>' + trimmedString + '...</p>';
            output += '</div></div></div>';
            return k < 3;
        });
        $content.html(output);
    }
  });
});
$(函数(){
var$content=$(“#jsonContent”);
风险值数据={
rss_url:'https://medium.com/feed/@女创始人
};
$.get('https://api.rss2json.com/v1/api.json,数据,函数(响应){
如果(response.status=='ok'){
var输出=“”;
$.each(response.items,function(k,item){
可见变异;
if(k<3){
visibleSm='';
}否则{
visibleSm=‘visibleSm’;
}
输出+='';
输出+='';
输出+=''+$.format.date(item.pubDate,“dd
MMM”)+“”; var tagIndex=item.description.indexOf(“”; 输出+=''; 输出+='按'+item.author+''; var yourString=item.description.replace(//*>/g,“”;//替换为字符串。 var maxLength=120//要提取的最大字符数 //将字符串修剪到最大长度 var trimmedString=yourString.substr(0,maxLength); //重新修剪,如果我们在一个词的中间 trimmedString=trimmedString.substr(0,Math.min(trimmedString.length,trimmedString.lastIndexOf(“”)) 输出+=''+trimmedString+'…

'; 输出+=''; 返回k<3; }); $content.html(输出); } }); });
当前配置文件输出:

所需的配置文件输出:


您得到的图像是错误的,因为您在搜索
时得到的第一个结果是错误的,因为您在搜索
时得到的第一个结果是错误的
var tagIndex = item.description.indexOf('<img', item.description.indexOf('<img') + 1);