【发布时间】:2020-02-06 08:59:32
【问题描述】:
我正在尝试从 YouTube 频道获取一些详细信息,但这并没有给我想要的输出。
我尝试了以下代码来获取 YouTube 视频链接:
import requests
import urllib.request as ur
import pandas as pd
username = "Google"
path = "https://www.youtube.com/user/Google/videos"
alldata = str(requests.get(path).content).split(' ')
item = 'href="/watch?'
vids = [line.replace('href="', 'https://www.youtube.com') for line in alldata if item in line] # list of all videos listed twice
print(pd.DataFrame(vids))
电流输出: 这段代码给了我大约。 30-40 个视频链接作为输出,但在给定页面中几乎超过 1000 个视频可用。
预期输出: 我想提取此页面中所有(1000+)个视频链接。
我需要在上面的页面中进行哪些更改才能获得预期的输出?
感谢您的宝贵时间。
【问题讨论】:
标签: python-3.x youtube python-requests