473,387 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

running a web page from python

SimonJ621
Hi all,

I have an python application that I would like to use to send some data to a web page. I am sending this data via url encoding to pass some variables to the page. While I can get the server side to process the data on the web page I'm sending data to, I can't get the javascript to execute. Here are the two things I have tried:

A)
Expand|Select|Wrap|Line Numbers
  1. import urllib
  2. # Send a 'GET' request to protoSender
  3. data = urllib.urlencode({'LEGACY_ID' : 'work', 'BU_SOURCE_INDICATOR' : etc....})
  4. f = urllib.urlopen("http://www.blackspyraldancer.com/cardinal/protoSender.php?%s" % data)
  5. s = f.read()
B)
Expand|Select|Wrap|Line Numbers
  1. import webbrowser 
  2. # open browser with url encoded
  3. webbrowser.open("http://localhost/protosender.php?LEGACY_ID=1111&BU_SOURCE_INDICATOR=9999&etc....", new=0)

The problem with A is that the client side javascript doesn't run (which is used to send some xmlRequestObjects). I realize this is because the browser isn't launched and therefore not available to run the javascript.

B opens a browser and runs the page correctly, but it won't open the site in the same browser window (despite what it's supposed to do). Because this application will be running many many times, I wouldn't be able to keep opening new browsers windows.

I would appreciate any help. Thank you.

Jason


-------------------------------------------------------------------
http://www.elefoo.com/
http://www.blackspyraldancer.com/
Aug 2 '07 #1
8 1937
Andelys
47
I can see your problem... But is it necessary to execute javascript? because that would be very hard to get it work (i'm talking about example A).

In example B, maybe you could make you program open a browser like "C:\Program Files\Internet Explorer\ieexplore.exe [url]", and then after a amount of time it will close it... I don't know how you can make that, and i dont know if its possible, just a idea :)

Andelys over and out ;)
Aug 2 '07 #2
Thanks for the reply and suggestion. My temporary solution (very similar to your suggestion) is to run window.close when the xml http response comes back. The code looks like this:
Expand|Select|Wrap|Line Numbers
  1.     function XMLResults(){
  2.       if(request.readyState == 4){
  3.         if(request.status == 200){
  4.           // var strText = request.responseText;
  5.           // document.getElementById("confirmation").innerHTML = strText;
  6.           window.open('','_parent','');
  7.           window.close();
  8.         }
  9.         else{
  10.           alert("There was a problem retrieving the XML data:\n" + reqXML.statusText);
  11.         }
  12.       }
  13.     }
I'm not sure yet if this will suffice based on performance, so I'm still open to suggestions.

Thanks,
Jason

-----------------------------------------------------------
http://www.elefoo.com/
http://www.blackspyraldancer.com/
Aug 2 '07 #3
Andelys
47
You could do that, but if it's your homepage, then why do you have to run javascript? could you recode that so it doesn't have to use javascript?
Aug 2 '07 #4
Well... there really isn't a homepage in this application. I am using a browser to send an http xml request, but I'm calling that browser from another program (Business Objects Data Quality). This is to build a prototype to test how some data reacts to the same transforms that are being used in an earlier project, not the actual process flow. This page will be requested about 10,000 times from Business Objects in a only a few minutes. We'll see if the computer crashes when I test it :).

We already have another Java solution that converts a delimited flat file written by Business Objects into XML for further downstream activities. This is merely to see if such a solution is feasible.
Aug 2 '07 #5
Andelys
47
I'm pretty sure that it will lack or crash. It's also a dirty solution.

But, tell me if it work :D just PM me
Aug 2 '07 #6
Dirty, yes... I'm just curious at this point what happens. It's been a while since I've been able to crash a system :) I'll PM you the results when I test it.
Aug 2 '07 #7
Andelys
47
I'm crossing my fingers for you :)

Andelys - over and out ;)
Aug 2 '07 #8
autoit can be used as a com object If you are using windows that may be a good answer or to use internet explorer as a com object.. sendkeys is also another library that could be helpfull to send key press's to a program...
Aug 6 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Andrew Chalk | last post by:
I am developing a CGI app, When the user loads my page I want to populate an HTML 'select' box (drop down menu) with items from a database. What is the best way to get my Python procedure that does...
3
by: G.A. | last post by:
I've installed Eclipse 3.0 and the latest pyeclipse. I can get the editor run - at least I think so, because it seems to do reasonable syntax highlighting. However, I can't get the Python console...
23
by: Spiffy | last post by:
hello, i'm fairly new to python programming and programming in general, but i have written a python prog that creates a MIDI file (.mid) and I want to be able to play it from another prog which is...
2
by: Eric Ching | last post by:
Can I run pythonw with a script that takes command line arguments then launches a GUI? I try pythonw myscript.pyw -option arg (etc.) and nothing happens. Nothing, as in I am immediately returned...
3
by: Edg Bamyasi | last post by:
This Is A Late Cross Post from comp.lang.python. It seems the mistery is deeper then i expected. What is the running time of conactination on character strings. i.e. >> joe="123" >>...
1
by: chris.levis | last post by:
All: I have written a Python webapp under MS IIS 5.0 that does the following: -Does a CVS checkout of a particular bit of xml -Gets a list of valid cvs tags for that xml file -Based on user...
9
by: Matt Helm | last post by:
I am starting the design phase of a large project (ERP) where the backend will mostly be Python (or Ruby) providing web services. In this type of usage, is there any benenfit to running under...
8
by: geert | last post by:
Hi all, I have a mac mini running maocosx 10.5 leopard I want to deploy a django project on. My backend is MySQL, and I have it running as a 64- bit app. Of course, apache2 is also running as...
1
by: mpc | last post by:
hello, how does one run a PHP page with a python webserver? Lets say i have a simple python web server running /path/webserver.py #!/usr/bin/env python from BaseHTTPServer import HTTPServer...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.