Python 3 Web Scraping Script to Scrape & Parse Live Blog RSS Feed & Export to XML & CSV File
68 views
Jun 3, 2025
Get the full source code of application here: https://codingshiksha.com/python/python-3-web-scraping-script-to-scrape-parse-live-blog-rss-feed-export-to-xml-csv-file/
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:06
uh parse RSS block feed of any website
0:10
that provides a RSS
0:13
feed I will show you how to scrape that
0:15
RSS feed and save it inside uh XML and
0:20
CSV formats So this is actually this
0:23
Python script that I have written So I'm
0:26
just scraping this uh RSS feed right
0:29
here by the URL You can
0:33
see every blog website provides it RSS
0:39
feed So it's in XML format right here if
0:42
you see it's accessible It's publicly
0:46
accessible So whenever a blog post a
0:50
popular website they do offers RSS blog
0:53
feed So now as soon as I execute this
0:57
Python script you will see on the left
0:59
hand side it will download this RSS feed
1:02
and then it will export this to CSV
1:05
format as well So let me execute this
1:08
and just check out on the left hand side
1:10
you will see
1:22
So just check on the left hand side It
1:24
created two files here Uh first of all
1:27
it downloaded the RSS feed of the block
1:30
in XML format and then it converted this
1:34
XML to a
1:36
CSV So first of all it fetched this RSS
1:40
feed in this XML format and then it
1:43
converted this XML to CSV
1:49
So this single script is doing all this
1:53
So it is fetching first of all the RSS
1:55
feed in the XML and then it is
1:58
converting this to
1:59
CSV So I have given all this Python
2:03
script in the description of this video
2:05
So now let me show you step by step how
2:08
I did this
2:10
So for this we aren't using any third
2:13
party module So just create a simple app
2:18
py file and after that just include the
2:21
basic modules the CSV module then you
2:25
need to import the request module to
2:28
make the request and then you just need
2:31
to import the XML
2:33
dot this module here like this and after
2:39
that here you just need to
2:43
specify you just need to make some
2:46
custom functions right is so first of
2:49
all load RSS So this will fetch the RSS
2:54
feed So let me just make this
3:02
function So the very first thing we do
3:05
inside this function we specify the
3:09
URL in the publicly accessible RSS feed
3:13
URL You just need to paste here
3:16
So you can take any website URL which
3:21
provides you with the RSS blog feed
3:24
right here So just paste that After that
3:27
you just need to make the simple request
3:30
to this URL by the request module So
3:33
request dot get and then pass it the
3:36
actual
3:37
URL As soon as you make the request here
3:40
we just need to download that XML file
3:43
the RSS blog XML file here So for that
3:48
we can simply use the open function and
3:50
just give it a file name
3:54
result.xml save this file in read binary
3:57
mode
3:58
uh like this
4:00
F.Right to write the content which is
4:04
coming So response
4:07
dot content So in this way you can
4:10
actually download the XML file this
4:13
programmatically So if you run this
4:15
script now let me delete
4:21
everything So if I execute the script
4:24
here you will see on the left hand side
4:26
uh
4:35
The result.xml file will be
4:47
created So after doing this you need to
4:50
pass this XML which is coming So we will
4:54
be having the second function here
5:08
So here you just need to pass the file
5:10
name to
5:14
this So this will actually
5:17
pass this
5:19
XML which is there in the block feed
5:26
It will actually take the XML file as an
5:28
argument and then it will analyze the
5:31
overall XML file It will extract the
5:34
relevant information and create a new
5:39
file which will be
5:41
result.xml
5:48
So if I now execute this
5:55
And lastly we need to convert this RSS
5:59
blog feed to a CSV file So we are making
6:02
the third function which is save to CSV
6:05
And here we are simply passing the
6:08
content And this time we are creating a
6:10
new file which is the CSV file
6:19
So as you can see first of all it
6:21
created this XML file then it created
6:23
this CSV file
6:26
So so you can take any RSS blog feed
6:29
example and just plug this inside the
6:32
script and the script will automatically
6:35
download the XML file and then it will
6:37
convert that into
6:39
CSV So I've given this script in the
6:41
description of this video
6:46
So so thank you very much for watching
6:49
this video and also check out my website
6:52
freemediattools.com
6:54
uh which contains thousands of tools