I am trying to write a python script that checks money.rediff.com for a specific stock price and prints it. I know that this can be easily done using the API, but I want to find out how urllib2 works, so I try to do it the old way. But I was fixated on how to use urllib. Many online tutorials have asked me to “Check the item” for the value I need to return and split the string to get it. But all the examples in the video make it easy to separate the HTML tags, but I have something like this:
<div class="f16">
<span id="ltpid" class="bold" style="color: rgb(0, 0, 0); background: rgb(255, 255, 255);">6.66</span>
<span id="change" class="green">+0.50</span>
<span id="ChangePercent" style="color: rgb(130, 130, 130); font-weight: normal;">+8.12%</span>
</div>
I only need "6.66" in Line2. How should I do it? I am very new to Urllib2 and Python. All help would be greatly appreciated. Thanks in advance.
source
share