【发布时间】:2020-07-06 22:36:46
【问题描述】:
from GoogleNews import GoogleNews
import sys
f = open("googlenewsx.txt", "w")
keywordlist = ['Apple', 'Pear','Orange']
googlenews = GoogleNews()
for word in keywordlist:
googlenews.search(word)
googlenews.setTimeRange('15/05/2020','15/06/2020')
googlenews.getpage(1)
results = googlenews.result()
listofres = []
for ting in results:
title = ting['title']
date = ting['date']
link = ting['link']
listofres += [[title, date, link]]
f.write("%s, %s, %s \n" %(title, date, link))
#print(listofres)
#f.close()
我的代码使用 Python 上的 GoogleNews 模块,并且仅适用于列表中的第一个术语。所以它只搜索第一个单词并继续搜索第一个单词。我怎样才能让它搜索我列表中的每个术语?我对编码完全陌生。
【问题讨论】:
-
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。