주어진 URL에서 파이썬 코드로 유튜브 제목과 설명을 가져 오는 방법. YouTube API를 사용해야 할 필요가 있습니까? 나는 주어진 URL에서 제목과 설명을 찾아야하는 프로그램을 작성 중입니다파이썬 코드를 사용하여 주어진 url에서 유튜브 제목과 설명을 가져 오는 방법은 무엇입니까?
답변
필요하지 않습니다. 그러나 자신의 글을 작성하는 것보다 훨씬 빠르고 쉽습니다. 자세한 내용은
, 당신은 정말 개발자 키를 사용하여 YouTube에서 추적을받지 않고 스스로를 작성하려는 경우, 당신은 단순히 수,
import gdata.youtube
import gdata.youtube.service
yt_service = gdata.youtube.service.YouTubeService()
# authorize - you need to sign up for your own access key, or be rate-limited
# yt_service.developer_key = 'ABCxyz123...'
# yt_service.client_id = 'My-Client_id'
def PrintEntryDetails(entry):
print 'Video title: %s' % entry.media.title.text
print 'Video published on: %s ' % entry.published.text
print 'Video description: %s' % entry.media.description.text
print 'Video category: %s' % entry.media.category[0].text
print 'Video tags: %s' % entry.media.keywords.text
print 'Video watch page: %s' % entry.media.player.url
print 'Video flash player URL: %s' % entry.GetSwfUrl()
print 'Video duration: %s' % entry.media.duration.seconds
for entry in yt_service.GetTopRatedVideoFeed().entry:
PrintEntryDetails(entry)
대단히 감사드립니다. :-) – Tachyons
을 시도 gdata
모듈을 설치 한 후
https://developers.google.com/youtube/1.0/developers_guide_python 참조
https://gdata.youtube.com/feeds/api/videos/#{video_id}
https://gdata.youtube.com/feeds/api/videos/#{video_id}?alt=json
예를 들면 : : https://gdata.youtube.com/feeds/api/videos/fcz_DYms4N4 요청을 보낼. 필요에 따라 XML, JSON 또는 JSONP를 반환 할 수 있습니다.
URL 리소스를 더 이상 사용할 수 없어 V2 API를 더 이상 사용할 수 없기 때문에 두 답변이 더 이상 작동하지 않습니다. 정확히 어디
from apiclient.discovery import build
DEVELOPER_KEY = 'your api key goes here'
youtube = build('youtube', 'v3', developerKey=DEVELOPER_KEY)
ids = '5rC0qpLGciU,LgbuxTfJFr0'
results = youtube.videos().list(id=ids, part='snippet').execute()
for result in results.get('items', []):
print result['id']
print result['snippet']['description']
print result['snippet']['title']
Google 개발자 콘솔을 사용하여 API 키를 만든 후 완벽하게 작동했습니다. –
을 정보는 원래이다 :
이
는 V3 코드 작동되는? 문제에 따라 HTML 구문 분석기 나 정규 표현식을 쉽게 사용할 수 있지만 질문이 무엇인지 파악하기 란 쉽지 않습니다. 사이트를 탐색 중이며 모든 설명과 제목을 다운로드하고 싶습니까? 비디오의 URL을 넣고 그것을 잡고 싶습니까? – Trickfire