https://reurl.cc/yZgRXD
上面是用Python抓八卦版資訊,我不懂得是:
1.第29行有個articles = [] ,第71行也有個 articles = [],為什麼?如果都是要儲存
文章,那第71行的 articles = []需要寫嗎?
2.def get_author_ids(posts, pattern):
ids = set()
for post in posts:
if pattern in post['author']:
ids.add(post['author'])
return ids
這邊完全看不懂,而且跟前面那個抓作者的資料有關係嗎?他之前不就寫:
author = '' # author = d.find('div', 'author').text if d.find('div',
'author') else ''
那不就用#後面那行就好了?為什麼還要def get_author_ids這個函數?
請大大指教,感謝~~