Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Read Xml and make post request

Hey,

I'm trying to make a python script that accesses a server see the response from the server and use that response to make Post request.
The response is in XML and I need to make multiple post requests with the values between tags.
Any library or recommendation?

Example:

Code
#!/usr/bin/env python

import requests

i = 1

while True:
   bucket = requests.get("https://server.com/")
   print (bucket.text.encode('ISO-8859-1'))
   print (len(bucket.content))
   r = requests.post("http://server.com", data={'number': 12524, 'type': 'issue', 'action': 'show'})
   i = i + 1
   if(i > 100):
       break

input('Press ENTER to exit')
[Image: YZs1dv2.jpg]
(Aug 12, 2018 06:00 AM)Ownc0d3r Wrote:  Hey,

I'm trying to make a python script that accesses a server see the response from the server and use that response to make Post request.
The response is in XML and I need to make multiple post requests with the values between tags.
Any library or recommendation?

Example:

Code
#!/usr/bin/env python

import requests

i = 1

while True:
   bucket = requests.get("https://server.com/")
   print (bucket.text.encode('ISO-8859-1'))
   print (len(bucket.content))
   r = requests.post("http://server.com", data={'number': 12524, 'type': 'issue', 'action': 'show'})
   i = i + 1
   if(i > 100):
       break

input('Press ENTER to exit')

Use ElementTree from the xml module. https://docs.python.org/3/library/xml.et...ttree.html

ElementTree has a fromstring method that you can pass the XML response from the GET request. Is this for an S3 bucket?
(Aug 12, 2018 06:23 AM)TyrantKingBen Wrote:  Use ElementTree from the xml module. https://docs.python.org/3/library/xml.et...ttree.html

ElementTree has a fromstring method that you can pass the XML response from the GET request. Is this for an S3 bucket?

Yes, it is for S3 bucket! I'm going to check it out
[Image: YZs1dv2.jpg]
(Aug 12, 2018 06:33 AM)Ownc0d3r Wrote:  Yes, it is for S3 bucket! I'm going to check it out

I've used it for parsing the ListBucketResult object. It should be pretty straightforward to implement for any of the S3 API endpoints, but there is something called Boto 3 (https://boto3.readthedocs.io/en/latest/g...start.html) that you might look into if you are going to be hitting a lot of different endpoints. I haven't used it personally, but it has a lot of good documentation.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by offpageseoAug 25, 2016 08:49 AM 3 137 Aug 25, 2016 08:49 AM
Last Post: Elitas
[.NET] by huntersMar 2, 2016 07:24 PM 8 192 Mar 2, 2016 07:24 PM
Last Post: Support™
[C#] by Angel Beats‌‌Aug 13, 2014 05:12 AM 5 104 Aug 13, 2014 05:12 AM
Last Post: Only3