samedi 27 juin 2015

how to pass value from output to a string in python

I've been trying to make an application in python and I'm new to python. Well, what I actually want to do is that . I want the feedparser to read the values from an RSS of a website... say reddit... and then I want to make that output as a stringand pass the value further to my code... my code right now..

import feedparser
import webbrowser

feed = feedparser.parse('http://ift.tt/11qcD9m')
print feed['entries'][1]['title'] 
print feed['entries'][1]['link'] 

It is working right now.. it parses the feed and I get the output I want... Now, I want to use the "link" from the "print feed['entries'][1]['link'] " and use it in the code further... how can I do so..? To be more specific.. I want to open that URL in my browser... I concluded to something like this..

import feedparser
import webbrowser

feed = feedparser.parse('http://ift.tt/11qcD9m')
print feed['entries'][1]['title'] 
print feed['entries'][1]['link'] 

mystring = 'feed['entries'][1]['link']'
webbrowser.open('mystring')

It is of course not working... Please Help... if you need to know anything else.. please let me know...

Aucun commentaire:

Enregistrer un commentaire