🦊修复由于rss倒序导致抓取错误的问题 #18
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							@@ -146,8 +146,6 @@ def parse_feed(url, session, count=5):
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        for i, entry in enumerate(feed.entries):
 | 
					        for i, entry in enumerate(feed.entries):
 | 
				
			||||||
            if i >= count:
 | 
					 | 
				
			||||||
                break
 | 
					 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            if 'published' in entry:
 | 
					            if 'published' in entry:
 | 
				
			||||||
                published = format_published_time(entry.published)
 | 
					                published = format_published_time(entry.published)
 | 
				
			||||||
@@ -168,6 +166,11 @@ def parse_feed(url, session, count=5):
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            result['articles'].append(article)
 | 
					            result['articles'].append(article)
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        # 对文章按时间排序,并只取前 count 篇文章
 | 
				
			||||||
 | 
					        result['articles'] = sorted(result['articles'], key=lambda x: datetime.strptime(x['published'], '%Y-%m-%d %H:%M'), reverse=True)
 | 
				
			||||||
 | 
					        if count < len(result['articles']):
 | 
				
			||||||
 | 
					            result['articles'] = result['articles'][:count]
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        return result
 | 
					        return result
 | 
				
			||||||
    except Exception as e:
 | 
					    except Exception as e:
 | 
				
			||||||
        print(f"不可链接的FEED地址:{url}: {e}")
 | 
					        print(f"不可链接的FEED地址:{url}: {e}")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user