Saturday, June 15, 2019
Hello there ! In this post lets see how to parse feed urls using python. Feed urls are provided by websites to share their content in the form of either xml or json.
Sometimes it helps us to display our blog posts in our portfolio site. Of course you can also do this using domain mapping , but here we are restricted with the title of this post.
Sometimes it helps us to display our blog posts in our portfolio site. Of course you can also do this using domain mapping , but here we are restricted with the title of this post.
First lets install feedparser
pip install feedparserNow lets import feedparser and parse this blog.
import feedparser
d = feedparser.parse('http://glammingspace.blogspot.com/feeds/posts/default?alt=rss')
d.entries
here d.entries gives all the entries in the rss feed ,but let me put here tokenized output so that it keeps this page short. This tokenized output contains only some of main posts of this blog.
This is some large for a single post but there are more json like this, representing other posts as well . Now its time to retrieve the required fields in the above json.
First field goes for the post title
>>d.entries[0].title
'TCAV- Its time to rate the factors of neural network'
Hola ! we got our title. Here entries[0] stands for first JSON field.
>>d.entries[0].media_thumbnail
[{'url':'https://img.youtube.com/vi/8Bi-EhFPSLk/default.jpg', 'height': '72', 'width': '72'}]
>>d.entries[0].summaryWe got our image and summary too , This is how we get other fields too
Google I/O 2019 was more interesting for me to watch. There are eye catching innovations displayed in the conference. Among them TCAV (stands for Testing with Concept Activation Vectors ) grabbed my attention. Because Machine Learning engineers often keep believing on the algorithm itself,and are not concerned about the internal functioning of a neural network. In some cases bias play a
Happy Parsing ..!
Saturday, June 15, 2019
python
0 Response to Parsing feeds in python using feedparser
Comments are personally moderated by our team. Promotions are not encouraged.
Post a Comment