获取视频上传的确切时间
我正在使用 Youtube API 进行搜索关键字查询:
import gdata.youtube
import gdata.youtube.service
def youtube_query(query_text,
max_results=50,
start_index=1,
racy='exclude',
orderby='relevance'):
client = gdata.youtube.service.YouTubeService()
query = gdata.youtube.service.YouTubeVideoQuery()
query.vq = query_text
query.max_results = max_results
query.start_index = start_index
query.racy = racy
#query.format = 5
query.orderby = orderby
feed = client.YouTubeQuery(query)
resultsCount = int(feed.total_results.text)
entries = []
try:
while resultsCount > int(query.start_index):
print repr(feed.entry)
entries += feed.entry
query.start_index = int(query.start_index) + int(query.max_results)
feed = client.YouTubeQuery(query)
except gdata.service.RequestError:
#
# Cannot request beyond 1000 items.
#
pass
return entries
每个条目都是一个 YoutubeVideoEntry< /a>.
每个视频上传的日期绝对应该是可访问的,因为每个视频都会显示该日期:
我也需要时间。有谁知道这是否可以做到?
I'm using the Youtube API to search using a keyword query:
import gdata.youtube
import gdata.youtube.service
def youtube_query(query_text,
max_results=50,
start_index=1,
racy='exclude',
orderby='relevance'):
client = gdata.youtube.service.YouTubeService()
query = gdata.youtube.service.YouTubeVideoQuery()
query.vq = query_text
query.max_results = max_results
query.start_index = start_index
query.racy = racy
#query.format = 5
query.orderby = orderby
feed = client.YouTubeQuery(query)
resultsCount = int(feed.total_results.text)
entries = []
try:
while resultsCount > int(query.start_index):
print repr(feed.entry)
entries += feed.entry
query.start_index = int(query.start_index) + int(query.max_results)
feed = client.YouTubeQuery(query)
except gdata.service.RequestError:
#
# Cannot request beyond 1000 items.
#
pass
return entries
Each entry is a YoutubeVideoEntry.
The date each video is uploaded should definitely be accessible, as it is displayed for every video:
I need the time as well. Does anybody know if this can be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
entry.published.text
属性:输出:
You can use the
entry.published.text
attribute:Output:
您还可以使用 iso8601 库中的 parse_date 函数,该函数将返回日期对象:
输出:
You can also use the parse_date function in the iso8601 library, which will return a date object:
Output: