2 Replies - 764 Views - Last Post: 24 January 2012 - 11:53 PM Rate Topic: -----

Topic Sponsor:

#1 MastaKay  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 12-November 07

HTTP requests using Python

Posted 24 January 2012 - 01:22 AM

Hi friends. We have two reporting processes. 1st is a report processing and FTP python script that run on our server. 2nd is a web page created by out London team, to upload the reports after the FTP process is complete. Both processes are working fine individually, but we need to merge the two. I have written the below code to incorporate onto the python process in order to automate the two.
try:
    new = 2 #open in a new tab
    TT = '2012-01-13'
    #I will pass the date(TT) to the webpage in order to upload reports for that date
    url = 'http://eqgn1.us.xp.com:18787/optionupload/OReportOServlet?dirpath=%%2Xport%%2Fdata%%2Fgpfs%%2Frts%%2FReport&cobdate=%s&submit=submit&operation=submit' % TT
    webbrowser.open(url, new=new)
    #webbrowser.select_form(nr=0)
except IOError:
    print 'Cannot open URL %s for reading' % url


My superiors do not like the idea of having a webpage opened each time the process is complete. Is there another way of updating the webpage using python without having to open the browser? I have been searching but cannot find anything as I am still new at this. Thank you in advance for your help

Is This A Good Question/Topic? 0
  • +

Replies To: HTTP requests using Python

#2 Motoma  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 443
  • View blog
  • Posts: 792
  • Joined: 08-June 10

Re: HTTP requests using Python

Posted 24 January 2012 - 06:49 AM

If nothing from the page is needed, you can use urllib to issue the HTTP request without opening the web browser. In Python 2.x you would replace webbrowser.open() with urllib.urlopen(); in Python 3 you would replace webbrowser.open() with urllib.request.urlopen().
Was This Post Helpful? 0
  • +
  • -

#3 MastaKay  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 12-November 07

Re: HTTP requests using Python

Posted 24 January 2012 - 11:53 PM

Thank you Motoma....I have been playing around with httplib, httplib2, and urllib, urllib2 but not winning....I will post my latest code shortly...I do not need anything from the page. I just need to update the "getdir" field and the "cobdate" field then submit
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1