Python 3 wget Library Script to Download HTML Source Code of Website Using URL in Terminal
62 views
Jun 3, 2025
Get the full source code of application here:
View Video Transcript
0:00
uh hello guys uh welcome to this video
0:02
So in this video I will show you how to
0:04
download the source code of any web page
0:07
inside a Python script using the wget uh
0:10
package Wget is actually a very handy
0:13
package by which you can actually
0:15
request the source code of any web
0:17
page And uh the command is simple First
0:21
of all you just need to install this
0:23
package pip install
0:26
wget Uh I've already installed it simply
0:29
execute this command to install this
0:31
package and then I have just written the
0:33
simple script here Uh you can see it is
0:37
uh downloading this article from this
0:40
website Uh
0:42
it's this is actually you can take any
0:45
website for
0:48
example So this is actually a web page
0:51
here So it's it will simply download
0:54
this inside
0:56
the your local hard disk If I run this
1:00
Python script here you will see
1:04
that it will save this
1:06
uh whole HTML web page to this location
1:11
So inside pages it will create this
1:13
pages directory You will see it will
1:15
download this HTML source code and uh it
1:18
will store it locally So now we can
1:21
start
1:24
this So if I start this you will see it
1:27
will run this localhost 3000 So now we
1:30
are running it inside offline without
1:33
internet internet connection So if you
1:35
want to download any web page locally
1:37
inside your machine using the python
1:40
script then for that you can actually
1:43
use this package wget So it's very
1:46
simple You s first of all require this
1:49
package wget and then you specify
1:52
whichever URL that you want to download
1:55
or let's suppose I take my own website
1:58
for example I take this web page for
2:01
example I copy the URL simply paste it
2:06
and then I just give it a file name and
2:09
uh I simply say wet dot it contains this
2:14
download function which actually fetches
2:17
the web page from this URL and we pass
2:21
the URL and then we mention the second
2:23
argument where to store it So inside
2:27
this we specify the location where we
2:29
need to store
2:31
it
2:35
So so here we'll be simply be mentioning
2:38
it where to create this So let me give
2:41
it a file name free media tools
2:47
HTML and then we can print out a simple
2:50
statement to the user that
2:52
your it successfully saved So now if you
2:56
run this Python script inside the
2:59
terminal just you will see it's saved If
3:03
I check it now you will see it will
3:05
create a new file free media tools html
3:08
It actually downloaded that full source
3:11
code of that specific HTML page that we
3:14
pasted If you see
3:16
that So we can now run this web page
3:19
locally You will see localhost 3000 So
3:22
we are running it locally So in this way
3:25
you can download any web page source
3:28
code inside your local machine You just
3:31
need to copy the URL and then paste it
3:33
inside the script So this module which
3:36
is wget module is a very handy module by
3:39
which you can first of all import that
3:42
you specify which URL that you want to
3:44
download Then it contains this download
3:46
function which downloads the fetches the
3:49
web page source code Uh thank you very
3:52
much guys for watching this video Uh
3:54
please hit that like button subscribe
3:56
the channel and also check out my
3:58
website freemediatools.com
4:00
uh which contains thousands of tools
#Internet & Telecom
#Web Services