Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web scraping Yoututbe被colab刮伤_Web Scraping_Video_Youtube_Google Colaboratory - Fatal编程技术网

Web scraping Yoututbe被colab刮伤

Web scraping Yoututbe被colab刮伤,web-scraping,video,youtube,google-colaboratory,Web Scraping,Video,Youtube,Google Colaboratory,我需要通过一些标签从YouTube上抓取汽车类视频,比如Google Colab: Abarth AC Acura Adam Adler AEC Aero Aixam Albion 因此,我尝试了以下两个代码在google colab中查找视频标签(例如tag='Peugeot'): !pip install youtube-search-python from youtubesearchpython import SearchVideos search = SearchVideos(&qu

我需要通过一些标签从YouTube上抓取汽车类视频,比如Google Colab:

Abarth
AC
Acura
Adam
Adler
AEC
Aero
Aixam
Albion
因此,我尝试了以下两个代码在google colab中查找视频标签(例如tag='Peugeot'):

!pip install youtube-search-python
from youtubesearchpython import SearchVideos

search = SearchVideos("NoCopyrightSounds", offset = 1, mode = "json", max_results = 20)

print(search.result())

但通过尝试此代码,它不会显示任何结果:

import urllib.request
from bs4 import BeautifulSoup

textToSearch = 'python tutorials'
query = urllib.parse.quote(textToSearch)
url = "https://www.youtube.com/results?search_query=" + query
response = urllib.request.urlopen(url)
html = response.read()
soup = BeautifulSoup(html, 'html.parser')
for vid in soup.findAll(attrs={'class':'yt-uix-tile-link'}):
    if not vid['href'].startswith("https://googleads.g.doubleclick.net/"):
        print('https://www.youtube.com' + vid['href'])
所以,我猜类名不正确!,我要求在这里调试它

更新: 我制作了一个google colab页面(如下所示)来测试这些代码(也是显示此错误的youtube dl代码:

错误:无法下载网页:HTTP错误429:请求太多 (原因);请报告此事 问题。请确保您使用的是最新版本 版本;请参阅如何更新。请确保 使用--verbose标志调用youtube dl并包含其完整的 输出

我理解这一错误是因为:

谷歌不喜欢从一个IP地址发出太多请求。

因此,尝试将这些标记(
--rm cache dir--force-ipv4--verbose
)添加到
youtube dl
命令中,如下所示(基于这些引用频率):


错误:无法下载网页:HTTP错误429:请求太多(由引起);请在上报告此问题https://yt-dl.org/bug 。请确保您使用的是最新版本;请参阅https://yt-dl.org/update  请确保使用--verbose标志调用youtube dl并包含其完整输出。
文件“/usr/local/lib/python3.6/dist packages/youtube\u dl/extractor/common.py”,第632行,在请求网页中
返回self.\u downloader.urlopen(url\u或\u请求)
urlopen中的文件“/usr/local/lib/python3.6/dist packages/youtube_dl/YoutubeDL.py”,第2238行
返回self.\u opener.open(请求,超时=self.\u套接字\u超时)
文件“/usr/lib/python3.6/urllib/request.py”,第532行,打开
响应=方法(请求,响应)
http\u响应中的文件“/usr/lib/python3.6/urllib/request.py”,第642行
“http”、请求、响应、代码、消息、hdrs)
文件“/usr/lib/python3.6/urllib/request.py”,第564行出错
结果=自身调用链(*args)
文件“/usr/lib/python3.6/urllib/request.py”,第504行,在调用链中
结果=func(*args)
http\u error\u 302中的文件“/usr/lib/python3.6/urllib/request.py”,第756行
返回self.parent.open(新建,超时=请求超时)
文件“/usr/lib/python3.6/urllib/request.py”,第532行,打开
响应=方法(请求,响应)
http\u响应中的文件“/usr/lib/python3.6/urllib/request.py”,第642行
“http”、请求、响应、代码、消息、hdrs)
文件“/usr/lib/python3.6/urllib/request.py”,第570行出错
返回自我。调用链(*args)
文件“/usr/lib/python3.6/urllib/request.py”,第504行,在调用链中
结果=func(*args)
文件“/usr/lib/python3.6/urllib/request.py”,第650行,默认为http\u error\u
raise HTTPError(请求完整的url、代码、消息、hdrs、fp)


谢谢。

它通过更改“ytsearch2000:”福特Festival“`:

“ytsearch50”:“Ford Festival”,如下所示:

!pip install youtube-dl 
# !youtube-dl --default-search gvsearch5:how to develop for android --no-playlist --write-info-json --write-annotation --write-thumbnail --write-sub --skip-download 
!youtube-dl --match-title 'ford' "ytsearch50":"Ford Festiva"+"peugeot 405"  --write-info-json --write-annotation --write-thumbnail --write-sub -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4'
这个问题是因为
位置错误

从谷歌抓取某款车型视频的完整代码如下:

请检查控制台或日志中是否有任何错误。我不熟悉Google Colaboratory,但问题可能出在您代码的其他部分。响应是否完全没有返回任何内容?-您的问题以及您从查询/请求中获得的结果。请检查此-引号:
我现在发现了问题,而且似乎没有使用另一个WIFI解决此问题。
。如果问题仍然存在,请分享您是否在web上搜索过此问题-同时检查是否有在上提出的问题。

ERROR: Unable to download webpage: HTTP Error 429: Too Many Requests (caused by <HTTPError 429: 'Too Many Requests'>); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/common.py", line 632, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/YoutubeDL.py", line 2238, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.6/urllib/request.py", line 564, in error
    result = self._call_chain(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 756, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)

!pip install youtube-dl 
# !youtube-dl --default-search gvsearch5:how to develop for android --no-playlist --write-info-json --write-annotation --write-thumbnail --write-sub --skip-download 
!youtube-dl --match-title 'ford' "ytsearch50":"Ford Festiva"+"peugeot 405"  --write-info-json --write-annotation --write-thumbnail --write-sub -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4'