[Tutor] running a javascript script with python

Alan Gauld alan.gauld at btinternet.com
Thu Nov 1 23:11:25 CET 2012


On 01/11/12 20:13, Benjamin Fishbein wrote:
> I'm on a website that produces an error the first time I submit text.

We need a lot more context and precision.

What OS, what web framework(if any) what Python version.

What does on a web site mean?
How are you submitting text?
Who created the Javascript - how does it relate to your Python code?
How are you running the Python code?

etc etc.

It may all seem self evident to you but I can assure
you it isn't to us!

> <script language='javascript'>function submitenter(myfield,e) {var keycode;if (window.event) {keycode = window.event.keyCode;}else if (e) {keycode = e.which;}else {return true;}if (keycode == 13) {myfield.form.submit();return false;}else {return true;}}</script>
>
> The part of my code that doesn't work is this:
>
> text=opener.open(url,encoded_data).read()
>
> ('opener' is an object that has all the cookies and headers put in place)
>
> The text always has the error.
>
> I tried this:
>
> for i in range(10):
> text=opener.open(url,encoded_data).read()
> if 'Error: BB-09-00-05' in text:
> print "Sorry, the error is there."
> else:
> print "Success!!!"
> print text
>
> The output is ten lines of "sorry, the error is there."

Can we see those ten lines please?
And where do they appear? In a browser? a server console?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list