I'm getting a (TypeError: expected string or bytes-like object) while working with pytube library
I'm getting a (TypeError: expected string or bytes-like object) while working with pytube library
python
from flask import Flask, request, render_template
from pytube import YouTube
import pytube
app = Flask(__name__)
@app.route("/", methods=["POST", "GET"])
def find():
search1 = request.form.get("search")
print(search1)
print(type(search1))
subt = pytube.YouTube(search1) # <-- Error occurs in this line.
print(subt)
cap = subt.captions.get_by_language_code('en')
print("Video english subtitle")
print(cap.generate_srt_captions())
return render_template("sub.html")
if __name__ == "__main__":
app.run(debug=True)
错误:
TypeError:预期的字符串或类似字节的对象
结果 = regex.search(字符串)
类型错误:预期的字符串或类字节对象
from flask import Flask, request, render_template
from pytube import YouTube
import pytube
app = Flask(__name__)
@app.route("/", methods=["GET"])
def index():
return render_template("sub.html")
@app.route("/test", methods=["POST"])
def find():
search1 = request.form.get("search")
print(search1)
print(type(search1))
subt = pytube.YouTube(search1)
cap = subt.captions.get_by_language_code('en')
print("Video english subtitle")
print(cap.generate_srt_captions())
return render_template("sub.html", cap=cap)
if __name__ == "__main__":
app.run(debug=True)
您可以使用此代码下载 youtube 字幕。
python
from flask import Flask, request, render_template
from pytube import YouTube
import pytube
app = Flask(__name__)
@app.route("/", methods=["POST", "GET"])
def find():
search1 = request.form.get("search")
print(search1)
print(type(search1))
subt = pytube.YouTube(search1) # <-- Error occurs in this line.
print(subt)
cap = subt.captions.get_by_language_code('en')
print("Video english subtitle")
print(cap.generate_srt_captions())
return render_template("sub.html")
if __name__ == "__main__":
app.run(debug=True)
错误: TypeError:预期的字符串或类似字节的对象
结果 = regex.search(字符串)
类型错误:预期的字符串或类字节对象
from flask import Flask, request, render_template
from pytube import YouTube
import pytube
app = Flask(__name__)
@app.route("/", methods=["GET"])
def index():
return render_template("sub.html")
@app.route("/test", methods=["POST"])
def find():
search1 = request.form.get("search")
print(search1)
print(type(search1))
subt = pytube.YouTube(search1)
cap = subt.captions.get_by_language_code('en')
print("Video english subtitle")
print(cap.generate_srt_captions())
return render_template("sub.html", cap=cap)
if __name__ == "__main__":
app.run(debug=True)
您可以使用此代码下载 youtube 字幕。