Downloading file using IE from python

后端 未结 8 913
无人及你
无人及你 2021-02-04 15:38

I\'m trying to download file with Python using IE:

from win32com.client import DispatchWithEvents

class EventHandler(object):
    def OnDownloadBegin(self):
            


        
8条回答
  •  一生所求
    2021-02-04 16:17

    You don't need to use IE. You could use something like

    import urllib2
    data = urllib2.urlopen("http://website/file.xml").read()
    

    Update: I see you've updated your question. If you need to use a browser, then clearly this answer isn't appropriate for you.

    Further update: When you click the button which is generated by JavaScript, if the URL retrieved is not computed by the JavaScript, and only the button is, then you can perhaps retrieve that URL via urllib2. On the other hand, you might also need to pass a session cookie from your authenticated session.

提交回复
热议问题