sunsexsurf

cbr_coins_parser

Nov 30th, 2021 (edited)
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. '''
  2. [1]
  3. http://www.cbr.ru/development/memorable_coins/
  4.  
  5. [2]
  6. http://www.cbr.ru/CoinsBaseWS/CoinsBaseWS.asmx?op=GetMonetDetailInfo
  7. '''
  8.  
  9. #это - мой код:
  10.  
  11.  
  12. import requests
  13.  
  14. endpoint = "https://www.cbr.ru/CoinsBaseWS/CoinsBaseWS.asmx"
  15.  
  16. body = """
  17. <?xml version="1.0" encoding="utf-8"?>
  18. <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  19.    <soap12:Body>
  20.        <GetMonetDetailInfo xmlns="http://web.cbr.ru/">
  21.            <CatNumber>5111-0451</CatNumber>
  22.            <Eng>false</Eng>
  23.        </GetMonetDetailInfo>
  24.    </soap12:Body>
  25. </soap12:Envelope>
  26. """
  27.  
  28. body = body.encode('utf-8')
  29.  
  30. headers = {"Content-Type": "application/soap+xml; charset=utf-8",
  31.            "Content-Length": str(len(body)),
  32.            "host": 'www.cbr.ru',
  33.            'SOAPAction': "http://web.cbr.ru/GetMonetDetailInfo"
  34.         }
  35.  
  36. response = requests.get(url=endpoint, data = body, headers = headers)
  37.  
  38. # session = requests.session()
  39. # session.headers = {"Content-Type": "application/soap+xml; charset=utf-8"}
  40. # session.headers.update({"Content-Length": str(len(body))})
  41. # # session.headers.update({"host": 'www.cbr.ru'})
  42. # response = session.post(url=endpoint, data=body, verify=False)
  43.  
  44. print(response.status_code)
  45. print(response.text)
  46.  
  47. '''
  48. response.staus_code возвращает 200, ок, работает.
  49. но само тело - вообще не о том ((
  50. '''
Add Comment
Please, Sign In to add comment