try to evaluate free content delivery network (CDN) available on the
internet to offload your server load and push the contents nearer to
your clients...

here is the script that might help you to simply things...

$ cat ngcp.py
#!/bin/env python

from urllib2 import urlopen
import re

html = urlopen('http://ngcp.ph/power_situation.asp').read()

regex = re.compile('.*<td> ?(.+)<\/td>.*')

data = [ regex.match(line).group(1) for line in html.splitlines() if
regex.match(line)]

print data

OUTPUT:

$ ./ngcp.py
['System Capacity (MW)', '9581', '1645', '1240', 'System Peak (MW)',
'6956', '1373', '1270', 'Reserve (MW)*', '2351', '272', '0', 'System
Capacity (MW)', '9581', '9581', '9581', '1663', '1662', '1645',
'1112', '1139', '1240', 'System Peak (MW)', '6580', '6531', '6956',
'1150', '1172', '1373', '1181', '1184', '1270', 'Gross Reserve (MW)',
'3001', '3050', '2625', '513', '490', '272', '0', '0', '0']

fooler.

On Sat, Apr 11, 2015 at 9:51 AM, Roberto Verzola <rverz...@gn.apc.org> wrote:
> Hi pluggers!
>
> I've installed dropbox on Linux. I get responses when I type dropbox
> help, dropbox status, etc. It also says it is NOT running.
>
> When I run dropbox start, it say run "dropbox start -i" to install the
> daemon. I thought this would install dropboxd in memory.
>
> But "dropbox start -i" tells me to download the "Dropbox proprietary
> daemon", and then does a huge file transfer, without telling me what is
> really happening, only a horizontal bar that shows % progress (not
> actual size). And since it took minutes for it to reach 1%, I thought
> these were unusually huge files, for software I thought I already
> installed. So I canceled the transfer.
>
> Any advice?
>
> For context, the solution I am working on (Danny Ching, pls tell me
> if I'm on the right track), is to save the Luzon load curve jpeg that I
> can now properly generate (thanks to people here who helped out!), to a
> directory which will be mirrored on Dropbox, and which will then be
> shared with others interested in mirroring it on their servers.
>
> Let me know also if this is a good solution or if there's a simpler one.
>
> Here's another problem I already solved but it's an ugly klutz. NGCP
> makes available the daily power supply status of Luzon (also Visayas
> and Mindanao) at the url ngcp.ph/power_status.asp.
>
> I get an html file and buried within it is the information I want
> (Luzon MW capacity for the day).
>
> I'm looking for a more resilient and simpler way. if any, than the
> Python code below. It's a klutz, I know. The slightest change could
> break it. I tried Beautiful Soup but I can't seem to install it
> properly due to dependency problems that couldn't be resolved.
>
> Greetings to all,
>
> Obet
>
> Extracting Luzon MW capacity from the html file returned by
> ngcp.ph/power_status.asp:
>
>
> from HTMLParser import HTMLParser
>
> class HeadingParser(HTMLParser):
>
>         inHeading = False
>         prevdata = 'xxx'
>         done = False
>         capacity = []
>
>         def handle_starttag(self, tag, attrs):
>                 if tag == 'td' or tag=='p':
>                         self.inHeading = True
>
>         def handle_data(self, data):
>                 if self.inHeading:
>                         '''
>                         if not data.strip().isdigit(): print '\n'+
> data , else: print ', '+data.strip() ,
>                         '''
>                         if not self.done:
> self.capacity.append(data.strip()) if 'System Peak' in data: self.done
> = True
>         def handle_endtag(self, tag):
>                 if  tag == 'td' or tag=='p':
>                         self.inHeading = False
>
>
> def daysupply_asof():
>         hParser = HeadingParser()
>         f = open('ngcp.dat')
>         html = f.read()
>         f.close()
>         hParser.feed(html)
>         when = hParser.capacity[1].replace(',',' ').replace(')',
>         '').split()
>         return ' '.join([when[7], when[5], when[6], when[3], when[2]]),
>         hParser.capacity[3]
>
>
> _________________________________________________
> Philippine Linux Users' Group (PLUG) Mailing List
> http://lists.linux.org.ph/mailman/listinfo/plug
> Searchable Archives: http://archives.free.net.ph
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
http://lists.linux.org.ph/mailman/listinfo/plug
Searchable Archives: http://archives.free.net.ph

Reply via email to