Is it possible to automate postback from the client side?

One of my clients should periodically retrieve client data from a web service. The data itself is provided as CSV files using javascript email messages, as is most of the navigation on the service website.

Currently, the worst bottleneck in the whole system is the need for a person to enter a web page, go to the download page and manually add the downloaded file to the rest of the system.

Is it possible to automate the process of downloading files using postback? (Say, for example, through a shell script that can be run through cron?)

If so, what would you recommend as the most suitable tool for this?

+1
source share
2 answers

If someone comes across this question again, I found a solution:

The trick is to use Mechanize and a series of calls Browser.submit()on the corresponding pages.

One freeze that others might encounter is that ASP.NET pages (the biggest source of postback navigation, in my experience) also need a hidden parameter __EVENTTARGETin a form that won't exist when you use mechanization.

The function __doPostBack('foo')on these pages gives the corresponding value __EVENTTARGETthrough the javascript onclick event on each of the links, but since mechanization does not use javascript, you will need to set these values โ€‹โ€‹yourself.

, :

def add_event_target(form, target):
    #Creates a new __EVENTTARGET control and adds the value specified
    #.NET doesn't generate this in mechanize for some reason -- suspect maybe is 
    #normally generated by javascript or some useragent thing?
    form.new_control('hidden','__EVENTTARGET',attrs = dict(name='__EVENTTARGET'))
    form.set_all_readonly(False)
    form["__EVENTTARGET"] = target

, , .

+4

AJAX Timer. asp.net/ajax -.

-1

All Articles