-1
我试图使用Alchemy API为URL列表提取关键字/实体 - 但是作为Python的相对新手 - 我不知道该怎么做这和我读过的无数堆栈溢出文章并没有让我产生任何结果。Python - 通过循环访问URL列表进行API调用
因此,有没有人知道我可以在列表中或在单独的txt/csv文件中对API列表进行API调用?
import json
from watson_developer_cloud import NaturalLanguageUnderstandingV1
from watson_developer_cloud.natural_language_understanding_v1 \
import Features, EntitiesOptions, KeywordsOptions
natural_language_understanding = NaturalLanguageUnderstandingV1(
username='Username',
password='Password',
version='2017-02-27')
response = natural_language_understanding.analyze(
url=('https://www.example.com/'),
features=Features(
entities=EntitiesOptions(
emotion=True,
sentiment=True,
limit=2),
keywords=KeywordsOptions(
emotion=True,
sentiment=True,
limit=2)))
print(json.dumps(response, indent=2))
你有什么试过,没有奏效?提示:“API调用”部分在这里完全不相关 - 问题是“我如何将单个项目的函数应用于列表(或任何其他迭代)的项目” –
nb:http://idownvotedbecau.se/noattempt/ –