473,715 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

running a web page from python

SimonJ621
12 New Member
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 xmlRequestObjec ts). 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.blackspyral dancer.com/
Aug 2 '07 #1
8 1945
Andelys
47 New Member
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\ieexpl ore.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
SimonJ621
12 New Member
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.blackspyral dancer.com/
Aug 2 '07 #3
Andelys
47 New Member
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
SimonJ621
12 New Member
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 New Member
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
SimonJ621
12 New Member
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 New Member
I'm crossing my fingers for you :)

Andelys - over and out ;)
Aug 2 '07 #8
eric dexter
46 New Member
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
1744
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 this called when the page is loaded? Many thanks
3
4999
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 window to appear (Unable to instantiate view: org.python.pyeclipse.views.ConsoleView), nor can I get python to run to completion. The MSWindows Task Manager shows that eclipse has successfully started python.exe (at least a process by that name...
23
1935
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 written in BASIC. It's a command-line prog that takes the MIDI filename as a parameter and plays the file. The 'Learning Python' book talks about using the os.system call, but I haven't been able to get this to work. How can I run this other...
2
6656
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 to the DOS prompt. I just started learning Python a couple of weeks ago, so please bear with me. I have a script that(for now) uses command line arguments then launches a window (Tk). Once I have entered the arguments and the window is...
3
2308
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" >> joe+="99999999999999999"
1
2025
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 input via forms, modifies that xml -CVS checkin's that file To have correct permissions to run the cvs binaries and to write
9
3758
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 Apache as opposed to a pure Python solution using Medusa, TwistedMatrix, or the like? Thanks, Matt
8
2774
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 64-bit. MySQLdb installs with the usual warnings after applying the various patches I found here and there. These patches consist of altering _mysql.c and site.cfg.
1
6925
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 from CGIHTTPServer import CGIHTTPRequestHandler serve = HTTPServer(("",8080),CGIHTTPRequestHandler)
0
8817
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8715
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9037
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7963
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6641
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5964
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4472
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.