0

One site Đ¿enerating iPXE build imagea file that I need to download by sending a request.

I want to make a request for a post on the 3th site (rom-o-matic.eu), and get a file from site. Is this possible?

My example is this:

def requestPOST(request):
    values = {'wizardtype': 'standard', 
    'outputformatstd': 'bin/ipxe.usb', 
    'embed': '#!ipxe dhcp route}', 
    'gitrevision': 'master'}

    r = requests.post("https://rom-o-matic.eu/", verify=False, data={values})
    return()

What should this return?

Thanks.

  • 1
    I recommend you to read the official "requests" documentation. You can find many examples there: http://docs.python-requests.org/en/master/user/quickstart/#more-complicated-post-requests – Antoine Apr 25 '17 at 07:35

1 Answers1

0
import requests
import shutil

def downloadPOST(outpath):
    values = {
        'wizardtype': 'standard', 
        'outputformatstd': 'bin/ipxe.usb', 
        'embed': '#!ipxe dhcp route}', 
        'gitrevision': 'master',
    }

    r = requests.get("https://rom-o-matic.eu/", data={values}, verify=False, stream=True)

    if r.status_code != 200:
        raise ValueError('Status code != 200')

    with open(outpath, 'wb') as f:
        r.raw.decode_content = True
        shutil.copyfileobj(r.raw, f)  

Based on How to download image using requests

Community
  • 1
  • 1
xakdog
  • 655
  • 6
  • 12