Capture some data from x with python

I tried to use http://www.jongsma.org/gc/scripts/ofx-ba.py to get information about my bank account from wachovia. No luck, I decided that I would just try to manually build some query data using this example

So, I have this file that I want to use as request data. Let me call it req.ofxsgml:

FXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE

<OFX>
  <SIGNONMSGSRQV1>
    <SONRQ>
      <DTCLIENT>20071015021529.000[-8:PST]
      <USERID>TheNameIuseForOnlineBanking
      <USERPASS>MySecretPassword
      <LANGUAGE>ENG
      <FI>
        <ORG>Wachovia
        <FID>4309
      </FI>
      <APPID>Money
      <APPVER>1700
    </SONRQ>
  </SIGNONMSGSRQV1>
  <BANKMSGSRQV1>
    <STMTTRNRQ>
      <TRNUID>438BD6F4-2106-4C88-8DE5-7625915A2FC0
      <STMTRQ>
        <BANKACCTFROM>
          <BANKID>061000227
          <ACCTID>101555555555
          <ACCTTYPE>CHECKING
        </BANKACCTFROM>
        <INCTRAN>
          <INCLUDE>Y
        </INCTRAN>
      </STMTRQ>
    </STMTTRNRQ>
  </BANKMSGSRQV1>
</OFX>

Then, in python, I try:

>>> import urllib2
>>> query = open('req.ofxsgml').read()
>>> request = urllib2.Request('https://pfmpw.wachovia.com/cgi-forte/fortecgi?servicename=ofx&amp;pagename=PFM',
                              query,
                              { "Content-type": "application/x-ofx",
                                "Accept": "*/*, application/x-ofx"
                              })
>>> f = urllib2.urlopen(request)

This command gives me 500 and this trace . I wonder what is wrong with my request.

Visiting a data-free URL and missing headers,

>>> f = urllib2.urlopen('https://pfmpw.wachovia.com/cgi-forte/fortecgi?servicename=ofx&amp;pagename=PFM')

gives the same as url directly,

HTTPError: HTTP Error 403: <BODY><H1>Request not allowed</H1></BODY>.

, . . python ofx . , - , ?

EDIT - :

d = {'ACCTID': '10555555',
 'ACCTTYPE': 'CHECKING',
 'APPID': 'Money',
 'APPVER': '1700',
 'BANKID': '061000227',
 'DTCLIENT': '20071015021529.000[-8:PST]',
 'FID': '4309',
 'INCLUDE': 'Y',
 'LANGUAGE': 'ENG',
 'ORG': 'Wachovia',
 'TRNUID': 'I18BD6F4-2006-4C88-8DE5-7625915A2FC0',
 'USERID': 'm48m40',
 'USERPASS': '12397'}

urlencode

query=urllib.urlencode(d)
request = urllib2.Request('https://pfmpw.wachovia.com/cgi-forte/fortecgi?servicename=ofx&amp;pagename=PFM',
                              query,
                              { "Content-type": "application/x-ofx",
                                "Accept": "*/*, application/x-ofx"
                              })

f = urllib2.urlopen(request)
HTTP Error 403: <BODY><H1>Request not allowed</H1></BODY>
+3
2

? ( therof?)

0

, Request. , , , , . , .

HTTP 403 , , . -, ? - , , ?

+2

Source: https://habr.com/ru/post/1721611/


All Articles