regexorcist
New Member
- Joined
- Feb 1, 2010
- Messages
- 178 (0.03/day)
- Location
- ~/
System Name | Slackware Linux |
---|---|
Processor | yes |
Motherboard | yes |
Cooling | currently convection, but considering mineral oil |
Memory | sometimes fails due to too much beer |
Video Card(s) | ATI Radeon HD5570 series |
Storage | IDE |
Display(s) | 32" LCD TV |
Case | sometimes |
Audio Device(s) | huh? what? speak up, I can't hear you |
Power Supply | yes |
Software | Slackware running Open-Source software (it doesn't get any better) |
This thread is for very simple python scripts or python code snippets.
As promised here:
http://forums.techpowerup.com/showpost.php?p=1752052&postcount=14
A Simple Python RSS Feed parser for the Tech Power Up site only.
There are better libraries to use and better ways of parsing an RSS feed,
but it's not a bad learning script.
Here is an image of it running in a shell on my desktop.
(I piped it into "more" so it would stop on the first page)
MORE SCRIPTS TO COME
As promised here:
http://forums.techpowerup.com/showpost.php?p=1752052&postcount=14
A Simple Python RSS Feed parser for the Tech Power Up site only.
There are better libraries to use and better ways of parsing an RSS feed,
but it's not a bad learning script.
Code:
#!/usr/bin/python
import sys
import string
from urllib2 import urlopen
import xml.dom.minidom
var_xml = urlopen("http://www.techpowerup.com/rss/")
var_all = xml.dom.minidom.parse(var_xml)
var_page_title = var_all.getElementsByTagName("title")[0].firstChild.data
var_page_link = var_all.getElementsByTagName("link")[0].firstChild.data
var_page_editor = var_all.getElementsByTagName("managingEditor")[0].firstChild.data
var_page_date = var_all.getElementsByTagName("pubDate")[0].firstChild.data
var_page_description = var_all.getElementsByTagName("description")[0].firstChild.data
print "--------------------------------------------------"
print "RSS Feed Title: ", var_page_title
print "URL Link: ", var_page_link
print "Managing Editor: ", var_page_editor
print "Published Date: ", var_page_date
print " "
print var_page_description
print "--------------------------------------------------"
print " "
for item in var_all.getElementsByTagName('item'):
var_title = item.getElementsByTagName('title')[0].firstChild.data
var_link = item.getElementsByTagName('link')[0].firstChild.data
var_description = item.getElementsByTagName('description')[0].firstChild.data
var_date = item.getElementsByTagName('pubDate')[0].firstChild.data
var_author = item.getElementsByTagName('author')[0].firstChild.data
print "Title: ", var_title
print "URL Link: ", var_link
print "Author: ", var_author
print "Published Date: ", var_date
print " "
print var_description
print "--------------------------------------------------"
print " "
Here is an image of it running in a shell on my desktop.
(I piped it into "more" so it would stop on the first page)
MORE SCRIPTS TO COME