Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6639895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:36:29+00:00 2026-05-25T23:36:29+00:00

EDIT: Problem solve. Ultimately it turned out to be a matter of http: instead

  • 0

EDIT: Problem solve. Ultimately it turned out to be a matter of “http:” instead of “https:” in the url (just a stupid mistake on my part). But it was the nice clean code example from cetver that helped me isolate the problem. Thanks to all who offered suggestions.

Putting this url in firefox triggers the appropriate download and save-as dialog:

https://www.virwox.com/orders.php?download_open=Download&format_open=.xls

The above link is same as submitting form with a “download” button of form on the page https://www.virwox.com/orders.php.

Here is the relevant html for the form that generates the above url:

<form action='orders.php' method='get'><fieldset><legend>Open Orders (2):</legend>
  <input type='submit' value='Download' name='download_open' /> 
  <select name='format_open'>
    <option value='.xls'>.xls</option>
    <option value='.csv'>.csv</option>
    <option value='.xml'>.xml</option></select>
</form>

But when I try the following python code (which I sort of expected would not work)…

# get orders list
openOrders_url = virwoxTopLevel_url+"/orders.php"
openOrders_params = urlencode( { "download_open":"Download", "format_open":".xml" } )
openOrders_request = urllib2.Request(openOrders_url,openOrders_params,headers)
openOrders_response = virwox_opener.open(openOrders_request)
openOrders_xml = openOrders_response.read()
print(openOrders_xml)

…openOrders_xml ends up just being the original page (https://www.virwox.com/orders.php).

How does firefox know there is also a file to be downloaded, and how do I detect and download this file in Python?

Please note that this is not a security/login issue, as I would not even be able to get the orders.php page if I was having authentication trouble.

EDIT: I am wondering if this has something to do with redirection (I am using the basic redirection handler) or maybe I should be using something liek urllib.fileretrieve().

EDIT: here is code for complete program, just in case is relevant…

import urllib
import urllib2
import cookielib
import pprint

from urllib import urlencode

username=###############
password=###############

virwoxTopLevel_url = "http://www.virwox.com/"

overview_url = "https://www.virwox.com/index.php"


# Header
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
headers = { 'User-Agent' : user_agent }

# Handlers...
# cookie handler...
cookie_handler= urllib2.HTTPCookieProcessor( cookielib.CookieJar() )
# redirect handler...
redirect_handler= urllib2.HTTPRedirectHandler()

# create "opener" (OpenerDirector instance)
virwox_opener = urllib2.build_opener(redirect_handler,cookie_handler)

# login
login_url = "https://www.virwox.com/index.php"
values = { 'uname' : username, 'password' : password }
login_data = urllib.urlencode(values)
login_request = urllib2.Request(login_url,login_data,headers)
login_response = virwox_opener.open(login_request)

overview_html = login_response.read();

virwox_json_url = "http://api.virwox.com/api/json.php"
getTest = urllib.urlencode( { "method":"getMarketDepth", "symbols[0]":"EUR/SLL","symbols[1]":"USD/SLL","buyDepth":1,"sellDepth":1,"id":1 } )
get_response = urllib2.urlopen(virwox_json_url,getTest)
#print get_response.read()

# get orders list
openOrders_url = virwoxTopLevel_url+"/orders.php"
openOrders_params = urlencode( { "download_open":"Download", "format_open":".xml" } )
openOrders_request = urllib2.Request(openOrders_url,openOrders_params,headers)
openOrders_response = virwox_opener.open(openOrders_request)
openOrders_xml = openOrders_response.read()

# the following prints the html of the /orders.php page not the desired download data:
print "******************************************"
print(openOrders_xml)

print "******************************************"
print openOrders_response.info()
print openOrders_response.geturl()
print "******************************************"
# the following prints nothing, i assume because without the cookie handler, fails to authenticate
#  (note that authentication is by the php program, not html authentication, so no "authentication hangler" above
print urllib2.urlopen("https://www.virwox.com/orders.php?download_open=Download&format_open=.xml").read()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:36:30+00:00Added an answer on May 25, 2026 at 11:36 pm

    CODE BELLOW ISN’T TESTED

    something like:

    import urllib, urllib2,
    
    HOST = 'https://www.virwox.com'
    FORMS = {
        'login': {
            'action': HOST + '/index.php',
            'data': urllib.urlencode( {
                'uname':'username', 
                'password':'******'
            } )
        },
        'orders': {
            'action': HOST + '/orders.php',
            'data': urllib.urlencode( {
                'download_open':'Download', 
                'format_open':'.xml'
            } )
        }
    }
    
    opener = urllib2.build_opener( urllib2.HTTPCookieProcessor() )
    try:
        req = urllib2.Request( url = FORMS['login']['action'], data = FORMS['login']['data'] )
        opener.open( req ) #save login cookie
        print 'Login: OK'
    except Exception, e:
        print 'Login: Fail'
        print e   
    try:
        req = urllib2.Request( url = FORMS['orders']['action'], data = FORMS['orders']['data'] )
        print 'Orders Page: OK'
    except Exception, e:
        print 'Orders Page: Fail'
        print e
    try:
        xml = opener.open( req ).read()
        print xml
    except Exception, e:
        print 'Obtain XML: Fail'
        print e
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

edit: I was trying to solve a spoj problem. Here is the link to
Edit: I fixed the problem by just starting from scratch. Sorry to waste y'alls
EDIT: The main problem seemed to be that I was just doing Add Existing
EDIT: I have managed to solve the problem by using: +lorem ipsum +type:photo +lorem
EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone
[Edit: This problem applies only to 32-bit systems. If your computer, your OS and
Edit 1: Uninstalled & Reinstalled Edit 2: Same problem. Seriously? Yes. I am having
Most of you probably know the following problem: You edit an HTML, view the
Edit : The bug that caused this problem has been fixed. The @version tag
EDIT: I have realized the source of my problem. I only have count information

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.