Alchemy API를 사용하여 URL 목록에 대한 키워드/엔티티를 추출하려고합니다. 그러나 Python에 대한 상대적 초보자로서 어떻게해야할지 모르겠습니다. 이것과 제가 읽은 수많은 Stack Overflow 기사는 저에게 어떤 결과도 가져 오지 않았습니다.Python - URL 목록을 통해 반복하여 API 호출 만들기
그러므로 누구든지 URL 목록이나 별도의 txt/csv 파일에서 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/ –