Coding A Simple Web Browser in Python
Вставка
- Опубліковано 10 лют 2025
- Today we build a simple web browser with a GUI in Python.
◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚
🐍 The Python Bible Book: www.neuralnine...
💻 The Algorithm Bible Book: www.neuralnine...
👕 Programming Merch: www.neuralnine...
🌐 Social Media & Contact 🌐
📱 Website: www.neuralnine...
📷 Instagram: / neuralnine
🐦 Twitter: / neuralnine
🤵 LinkedIn: / neuralnine
📁 GitHub: github.com/Neu...
🎙 Discord: / discord
🎵 Outro Music From: www.bensound.com/
The smile that hit my face when I opened my first browser was worth it. Thank you!
Another great use case for this (This is what i do in my projects sometimes): You can use this for creating awesome looking UIs. Just write a simple flask app and run the two things simultaneously so that now you can use HTML/CSS for UI instead of Qt5. I personally love using HTML/CSS so i use this trick for creating complex UIs in projects. Without the buttons on the top (go back, reload etc), it just looks like a window of some usual software.
But how do you get your flask app on the window
7:16
Use the setUrl function and pass in the localhost url your flask app is running on
@@addledanorak8297 but how would you show other webpages? And how would you keep the url bar and whatnot there
@@robinferizi9073 you can do that with html and js
@Robin Ferizi what I meant was to use the browser as a window that can show your flask project so that u can use html and css for ui and it looks like a professional software. That's all
Man, I need to say thanks! I crashed my head for an entire day trying to make a simple UI to stream a local server network content for a local community. I tried with socket, but I couldn't resolve my problem. Watching your video I understood that I could make a non navigable-browser with PyQt5. So a huge thanks!!
help bro that said like 16 error who are by the importatipon
@@Sebas0173YT you should check for the error and name of the library (pyqt5) on stackoverflow. I had issues with one of the methods and I had to install a separate library, but I don’t remember what it was. Something like qtweb
@@dicember92 I found how but how can i install an adblocker in this browser.
this is great for django/flask/fastapi based apps, as you can create a web window for the server without the user even realizing
So close to 100k, you can do it
Coming soon :D
yay finally i can do something that big tech companies do
nice short and easy to understand and follow man
This is not "coding web browser", it's just "using web browser" in your application.
Browsers basically use search engines to search and he is doing that. Making a browser doesn't mean you have to code the search engine yourself too
@@whereisyourhijabwhat search engine has to do with it? Do you even understand my comment.
@@cipherxen2 You are using lines of code to set up an interface to interact with websites. Ergo you are coding a web browser. You can use C in Windows to create a Desktop app that does the same thing, and it is still coding an GUI program that lets you browse the web, a "web browser". What, do you want him to write it from Assembly instead?
@@Logan_Wolf_Onlineso by your logic, if I write a program
import MyWebBrowser
MyWebBrowser()
Did I create a web browser? Or just used an existing one?
hey neuralnine. Don't use wildcard imports. Its not a good practice. It can affect the performance of the app.
I wanted to know the python book that you recommend in the description, do they only involve data structures and algorithms or they involve libraries that you use to make this Fire content?
Once again, really like your tutorial/projects on Machine learning
What software tool app did you download and use to create web browser in python?
You have been always great 👍
Oh , you using pyqt now!😲
Man my idle is spitting out 4 million syntax errors
hi i watching on your video with my web browser :D
just a question, how we can add tabs for the browser?
Brooooo Congo! This vid is getting views so fast!!!!!!!!
Rt
d0
4k to go man
Soon :)
?? years from now*
Man creates internet 2.0
Who's that? NeuralNine! :D
Great video! Wonder if this can be used for a custom selenium/browser automation type application. Excited to tinker with it, thanks!
I tried using selenium but it's painful
@@Victor_Marius nah its ez ur just inexperienced
@@qock1106 Selenium is painful because you have to keep the driver updated to the same version as the browser which can update automatically (Chrome). And some drivers won't work so easy
@@Victor_Marius naaah, it's easy if you know html and stuff as well
Great tutorial. Thanks.
This is what I searching for, thak you @nuralnine 😜
Great video-tutorials, amigo. You're good! And I have a question hoping you can answer: I have been trying to create an app where I can open three websites in three different QTabs. Using PyQt5 or PyQt6. But my sites have chats, and the chat doesn't load along with the website unless I use pywebview. So my question is: how can I add tabs to a window using pywebview and display a site in them, so I can select from a dropdown the site that I want to open (within the same window, not multiple windows)? Any help will be greatly appreciated! Keep up the great work, it helps more than you can imagine!
Can you post the source code somewhere?
Extremely useful, thank you. Do you have any resources on how to work with cookies on this?
its based on chromium so everything is already set up
After seeing your videos (which ones are really good), I was wondering if it is possible to create a UA-cam clone or Twitch clone with Python and Flask... I was trying to search the way to connect the OBS for live streaming to an specific app created on Python but no clue found on internet... maybe you know or you can help me with that question. Thanks!!
There is a cool tutorial on how to create a Twitter clone in Django (Yep, not Flask). ua-cam.com/video/f1R_bykXHGE/v-deo.html . I personally didn't finish it, but it was very useful.
well all the source code of twitch got leaked so if you got your hands on it you can def make a close to 100% clone
You copying my webcam positioning xD. Just kidding of course; thanks for the helpful tutorial!
Ahahah
what form of python are you using, my cmd line/prompt looks way different?
can you tell me why i can write it exactly as you do an check the install on mhy pips and its just like mmm nah
Hey, a quick question, is it possible to implement the console somehow? I want to make an app that can run JS code for you in the web browser, so, wondering if that is possible
You're gonna hit 100k this for sure!!! Trust me! BTW, I came here to get it motivated!
hey dude I did the code good but it don't work and also it has 17 errors and 2 weak warnings for some reason
I thank you for a very interesting and informative vid but for some reason it won't let me navigate to, or use an url, to get to a pdf url. Why could this be happening?
how much storage will python take up? with PyQt5 And whatever the other one is
Since it's only code(a LOT OF CODE) it probably shouldn't take more than 100mb but i doubt it will reach 100 mb
can you make a tutorial on how to code a adblocker for this browser
Really nice!
Hello. How do you download files from PyQt Browser?
please make this public on github I cant figure out whats wrong with my code
great video
thank you for guide
9:08 what is exit code -1?
The exit code is just a Boolean telling you if something went wrong. 1 means something did go wrong, and thus equates to true, and 0 means everything went as planned, and thus equates to false.
If you are having issues with the project opening when you added the back and forward buttons implemented as it is in the video, try typing "lambda: " before the self.browser forward and back functions. It works for me.
I click on run but nothing come up what should i do?
If you are having issues with the project opening when you added the back and forward buttons implemented as it is in the video, try typing "lambda: " before the self.browser forward and back functions. It works for me.
Thankyou is it possible to implement WebEngine view within a page
Does this work in IDLE?
The download process doesn't work when i press a downloadable link in any website. Should i add a feature to qwebengine or what must i do?
I solved the problem myself again. QT does not allow to download process normally. For do it, we must use QWebEngineDownloadItem class with downloadRequest signal. It was easily to use.
In mine it is showing pip is not recognized. Please help.
Thank you
how does it work with all video formats?
Well I though you are gonna make it from scratch 🤣
is there a way to put it on a usb? and transfer it to a different laptop
If that pc has py imstalled then yes
why dosnt this code work
from PyQt5.QtCore import QUrl
from PyQt5.QtGui import QIcon, QKeySequence
from PyQt5.QtWidgets import QApplication, QMainWindow, QTabWidget, QWidget, QVBoxLayout, QHBoxLayout, QLineEdit, QPushButton, QAction
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage
class InsecurePage(QWebEnginePage):
def certificateError(self, error):
return False
class BrowserTab(QWidget):
def __init__(self):
super().__init__()
self.layout = QVBoxLayout()
self.search_box = QLineEdit()
self.search_button = QPushButton("Search")
self.layout.addWidget(self.search_box)
self.layout.addWidget(self.search_button)
self.webview = QWebEngineView()
self.layout.addWidget(self.webview)
self.setLayout(self.layout)
self.search_button.clicked.connect(self.loadUrl)
self.search_box.returnPressed.connect(self.loadUrl)
def loadUrl(self):
url = self.search_box.text()
if not url.startswith("http"):
url = "" + url
self.webview.load(QUrl(url))
class BrowserWindow(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.tabs = QTabWidget()
self.setCentralWidget(self.tabs)
self.tabs.setTabsClosable(True)
self.tabs.tabCloseRequested.connect(self.closeTab)
# Create the menu bar
menu_bar = self.menuBar()
file_menu = menu_bar.addMenu("&File")
# Create a new tab action
new_tab_action = QAction(QIcon.fromTheme("tab-new"), "New &Tab", self)
new_tab_action.setShortcut(QKeySequence.New)
new_tab_action.triggered.connect(self.addNewTab)
file_menu.addAction(new_tab_action)
# Set the initial window properties
self.setWindowTitle("Python Browser")
self.setGeometry(100, 100, 800, 600)
# Add the initial tab
self.addNewTab()
def addNewTab(self):
tab = BrowserTab()
self.tabs.addTab(tab, "New Tab")
self.tabs.setCurrentWidget(tab)
def closeTab(self, index):
if self.tabs.count() > 1:
self.tabs.removeTab(index)
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
window = BrowserWindow()
window.show()
sys.exit(app.exec_())
It works fine when I run the codes from within pyCharm. But after converting it to exe via pyinstaller, the exe application works but does not show the web page in the window. It waits as a blank screen. Do you have an idea for this issue?
I solved the problem. It is necessary to use PySide2 instead of PyQt5. There is a licensing difference between them. The codes are exactly the same. Just use PySide2 instead of PyQt5 during import. But still i wonder that why PyQt5 don't show the web page. What does that have to do with PyQt5 licensing?
@@kaanakdik9455 thanks man
@@Pwnedby 👍
Somehow my python still doesn't recognize PyQt5, i've uninstalled and installed it so many times and it still doesn't recognize. What should i do?
i tried making a python env like venv
@@TheXtremerEditor I fixed it already, it was a year ago hahaha I'm currently using spyder
how the add videoplayer for twitch ?
Can anybody help me to add download & history button on this project cause my college mini project similar
Hey, can these browser access the dark web?
When I press the run buton it doesn't run. Why?
Am I able to add extensions and plugins and stuff?
no you can't. although it uses code from chromium (chrome is based on chromium) but its modified to work better with qt. all of the google services are striped out. so i think you can't install extensions.
@@MrinmoyHaloi I didn’t mean chrome extensions, I meant can I add native extensions and plugins
@@robinferizi9073 what do you mean by native plugins
@@MrinmoyHaloi I mean making my own plugins for my browser and making my own extension store instead of chrome extensions
I would say if you are good enough you can but then i remembered you asked this question, if you were good enough you wouldnt ask it soo i am saying no
can we make tabs with it?
thanks bro
"Simple web browser"
1) That's not "simple"
2) That looks like a real browser
3) Meanwhile me struggling to install windows
sir qtwebEngineWidgets not importing error
no tabs I can't login😭😭
anyone know if have way download file ? and upload ? with PQT 5 ?
Very bad
Its showing incorrect in the 7th line
I am trying to create a web browser using your video. It worked good, I can connect to my Disney+ account but the issue comes when I try to play a video.
It's seems that Dineyplus blocked access if it doesn't recognise the browser ?
Or a library PIP is missing ?
Could you help please ?
It's possible that Disney+ has implemented some form of browser detection to block access to their videos if the browser is not recognized. This is a common technique used by streaming services to prevent piracy and unauthorized access.
To work around this issue, you can try spoofing your browser's user agent to make it appear as a different browser that Disney+ recognizes. You can do this by adding an HTTP header to your requests with the user agent string of a known browser.
Flori mo bur je shqiptare. Bro are you Albanian your name means gold
Thx
Do it in C 💀
Please provide link of codes of your video in description. It is very helpful to get the codes in one place for coping.
using google na ?
How to add extensions ?
Watching tutorials, I keep seeing videos which seems like the people who may be attacking me online. Go figure, I'm subscribed to them. But, I wasn't to you? I just subscribed, I'm so confused. These other YT out here be hacking their viewers? 😂
cool
Why though
First!!
import browser
22second only
can somebody tell me why my browser don't work?
i cannot see the web pages
the code is this
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import *
class MyBrowser(QMainWindow):
def __init__(self):
self.window = QWidget()
self.window.setWindowTitle('MyBrowser')
self.layout = QVBoxLayout()
self.horizontal = QHBoxLayout()
self.url_bar = QTextEdit()
self.url_bar.setMaximumHeight(30)
self.go_btn = QPushButton("->")
self.go_btn.setMinimumHeight(30)
self.back_btn = QPushButton("«")
self.back_btn.setMinimumHeight(30)
self.forward_btn = QPushButton("»")
self.forward_btn.setMinimumHeight(30)
self.horizontal.addWidget(self.url_bar)
self.horizontal.addWidget(self.go_btn)
self.horizontal.addWidget(self.back_btn)
self.horizontal.addWidget(self.forward_btn)
self.browser = QWebEngineView()
self.go_btn.clicked.connect(lambda: self.navigate(self.url_bar.toPlainText()))
self.forward_btn.clicked.connect(self.browser.forward)
self.back_btn.clicked.connect(self.browser.back)
self.layout.addLayout(self.horizontal)
self.layout.addWidget(self.browser)
self.browser.setUrl(QUrl("google.com"))
self.window.setLayout(self.layout)
self.window.show()
def navigate(self, url):
if not url.startswith("http"):
url = "" + url
self.url_bar.setText(url)
self.browser.setUrl(QUrl(url))
app = QApplication([])
window = MyBrowser()
app.exec_()
Thank you, the Code works fine!
@@markusotte3442 ?
pls give me the code im to bord to do it