Alchemy APIを使用してURLのリストのキーワード/エンティティを抽出しようとしていますが、Pythonの相対的な初心者ではありませんこれと私が読んだ多くのStack Overflowの記事は、私に何の結果ももたらさなかった。Python - URLリストをループすることでAPIコールを作成する
したがって、リストや個別のtxt/csvファイルのいずれかでURLリストへの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/ –