Если в коде присутствуют ошибки, то их исправить. И вывести готовый рабочий код, который сработает:
Готовый код для основного файла main.py:

import sys
import os
import requests
from bs4 import BeautifulSoup
from urllib.parse import urlparse

from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import (
    QApplication,
    QMainWindow,
    QWidget,
    QVBoxLayout,
    QHBoxLayout,
    QLineEdit,
    QPushButton,
    QProgressBar,
    QFileDialog,
    QMessageBox,
    QInputDialog,
    QLabel,
)
from PyQt5 import QtCore, QtGui, QtWidgets
from pytube import YouTube

from internet import load_page


class MainWindow(QMainWindow):
    def init(self):
        super().init()
        self.setWindowTitle(“My Browser”)
        self.setWindowIcon(QIcon(“icon.png”))

        self.create_ui()

        self.history = []
        self.future = []

        self.show()

    def create_ui(self):
        widget = QWidget()

        # Строка поиска
        self.search_bar = QLineEdit()
        self.search_bar.returnPressed.connect(self.search)

        # Кнопки назад и вперед
        self.back_button = QPushButton(“<”)
        self.back_button.clicked.connect(self.back)

        self.forward_button = QPushButton(“>”)
        self.forward_button.clicked.connect(self.forward)

        # Кнопка скачивания видео
        self.download_button = QPushButton(“Download”)
        self.download_button.clicked.connect(self.download_video)

        # Кнопка настроек папки загрузки
        self.download_folder_button = QPushButton(“Download Folder”)
        self.download_folder_button.clicked.connect(self.choose_download_folder)

        # Прогресс-бар загрузки файлов
        self.progress_bar = QProgressBar()

        # WebView для отображения страницы
        self.web_view = QTextBrowser()
        self.web_view.setOpenExternalLinks(True)

        # Если пользователь кликнул по ссылке, то открываем ее в новом окне
        self.web_view.anchorClicked.connect(self.open_link_in_browser)

        # Располагаем элементы по горизонтали
        horizontal_layout = QHBoxLayout()
        horizontal_layout.addWidget(self.back_button)
        horizontal_layout.addWidget(self.forward_button)
        horizontal_layout.addWidget(self.search_bar)
        horizontal_layout.addWidget(self.download_button)
        horizontal_layout.addWidget(self.download_folder_button)

        # Располагаем элементы по вертикали
        vertical_layout = QVBoxLayout()
        vertical_layout.addLayout(horizontal_layout)
        vertical_layout.addWidget(self.web_view)
        vertical_layout.addWidget(self.progress_bar)

        widget.setLayout(vertical_layout)

        self.setCentralWidget(widget)

    def search(self):
        url = self.search_bar.text()

        if not url.startswith(“http”):
            url = “http://” + url

        try:
            response = requests.get(url)
            soup = BeautifulSoup(response.content, “html.parser”)

            self.current_url = url
            self.web_view.setHtml(str(soup))

            self.history.append(url)
        except:
            QMessageBox.warning(self, “Error”, “Failed to load page.”)

    def back(self):
        if len(self.history) > 1:
            self.future.insert(0, self.current_url)
            self.current_url = self.history[-2]
            self.history.pop()
            self.load_page(self.current_url)

    def forward(self):
        if self.future:
            self.history.append(self.current_url)
            self.current_url = self.future.pop(0)
            self.load_page(self.current_url)

    def download_video(self):
        url, ok = QInputDialog.getText(self, “Download Video”, “Enter YouTube URL:”)

        if ok:
            try:
                youtube = YouTube(url)
                video_title = youtube.title
                video_streams = youtube.streams.filter(type=“video”, progressive=True)

                options = []
                for i in range(len(video_streams)):
                    options.append(f"{i+1}. {video_streams[i].resolution}“)

                selected_option, ok = QInputDialog.getItem(self, “Select Quality”, “Select Video Quality:”, options, 0, False)

                if ok:
                    video = video_streams[int(selected_option[0])-1]

                    download_folder = self.download_folder or os.path.expanduser(”~“) # Если пользователь не выбрал папку, то скачиваем в домашнюю папку

                    video.download(download_folder, filename=video_title)
                    QMessageBox.information(self, “Success”, f"Video ‘{video_title}’ has been downloaded successfully.”)
                else:
                    QMessageBox.warning(self, “Error”, “Failed to select video quality.”)
            except:
                QMessageBox.warning(self, “Error”, “Failed to download video.”)

    def choose_download_folder(self):
        self.download_folder = QFileDialog.getExistingDirectory(self, “Select Directory”)

    def load_page(self, url):
        response = requests.get(url)
        soup = BeautifulSoup(response.content, “html.parser”)
        self.web_view.setHtml(str(soup))

        self.search_bar.setText(url)

    def open_link_in_browser(self, url):
        QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))

    def load_url(self, url):
        self.current_url = url

        if url.startswith(“http”):
            self.load_page(url)
        else:
            search_url = f"https://www.google.com/search?q={url}"
            self.load_page(search_url)


if name == “main”:
    app = QApplication(sys.argv)
    window = MainWindow()
    sys.exit(app.exec_())


Код для файла internet.py:

import requests
from bs4 import BeautifulSoup


def load_page(url):
    response = requests.get(url)
    soup = BeautifulSoup(response.content, “html.parser”)
    return soup