我第一次使用 Python 使用 API,在执行此操作时出现以下错误:
ValueError: cannot mix country/category param with sources param.
我应该怎么做才能解决这个错误?
这是代码:
import config
from newsapi import NewsApiClient
newsapi = NewsApiClient(api_key=config.api_key)
top_headlines = newsapi.get_top_headlines(q='Neuralink',sources='the-verge',category='technology',language='en',country='us')```
最佳答案
根据官方“NewsAPI”{https://newsapi.org/docs/endpoints/top-headlines} top-headlines 文档, “国家”和“类别”不能与“来源”参数同时使用。
关于python - ValueError:无法将国家/类别参数与来源参数混合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68544525/