Melih Onvural schrieb:
> I need to execute some javascript and then read the value as part of a 
> program that I am writing. I am currently doing something like this:
> 
> import htmllib, urllib, formatter
> 
> class myparser(htmllib.HTMLParser):
>       insave = 0
>       def start_div(self, attrs):
>               for i in attrs:
>                       if i[0] == "id" and i[1] == "pr":
>                               self.save_bgn()
>                               self.insave = 1
> 
>       def end_div(self):
>               if self.insave == 1:
>                       print self.save_end()
>               self.insave = 0
> 
> parser = myparser(formatter.NullFormatter())
> 
> #def getPageRank(self, url):
> try:
>       learn_url = "http://127.0.0.1/research/getPageRank.html?q=http://
> www.yahoo.com&"
>       pr_url = urllib.urlopen(learn_url)
>       parser.feed(pr_url.read())
> except IOError, e:
>       print e
> 
> but the result is the javascript function and not the calculated 
> value. Is there anyway to get the javascript to execute first, and 
> then return to me the value? thanks in advance,

Do it in a browser. There are ways to automate one, for example the 
webbrowser module, and others.

Then rework your script to work with AJAX.

Diez
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to