[text] g

Viewer

  1. import requests
  2.  
  3. # URLs for various actions
  4. select_options_url = 'https://toolkit.tesco.com/partner/reports/'
  5. save_options_url = 'https://toolkit.tesco.com/partner/reports/'
  6. download_report_url = 'https://toolkit.tesco.com/partner/reports/'
  7.  
  8. # Define options for each category/subcategory
  9. Country = ['UK', 'ROI']
  10. Report type = ['Sales and stock', 'Range conformance', 'Promotional funding', 'Auto sales out retro deals', 'Fulfilment fee', 'Performance summary', 'Cost price amendments', 'Purchase order amendments']
  11. Product subgroup = ['All product subgroups']
  12. products = ['All products']
  13. View = ['TPNB – Total sales', 'TPNB – Sales x store', 'TPNB – Sales x store format', 'TPNB - Sales x DC','Product subgroup - Total sales','Stores - Total sales','Store Format - Total sales']
  14. time_periods = ['Last full week (Wk 08']
  15.  
  16. # Iterate over combinations of options
  17. for country in Country:
  18.     for Report_type in Report type:
  19.         for product in products:
  20.             for view in View:
  21.                 for time_period in time_periods:
  22.                     # Send request to select options
  23.                     options_data = {
  24.                         'Country': country,
  25.                         'Report type': Report_type,
  26.                         'product': product,
  27.                         'view': view,
  28.                         'time_period': time_period
  29.                     }
  30.                     response_options = requests.post(select_options_url, data=options_data)
  31.                     # Check response if needed
  32.  
  33.                     # Simulate saving options (if applicable)
  34.                     save_options_data = {'save_option1': True, 'save_option2': False}
  35.                     response_save_options = requests.post(save_options_url, data=save_options_data)
  36.                     # Check response if needed
  37.  
  38.                     # Simulate clicking "Download Report" button
  39.                     response_download = requests.get(download_report_url)
  40.  
  41.                     # Check if download request was successful
  42.                     if response_download.status_code == 200:
  43.                         # Process the downloaded report file if needed
  44.                         with open('report.csv', 'wb') as f:
  45.                             f.write(response_download.content)
  46.                         print("Report downloaded successfully.")
  47.                     else:
  48.                         print("Failed to download report. Status code:", response_download.status_code)

Editor

You can edit this paste and save as new:


File Description
  • g
  • Paste Code
  • 25 Apr-2024
  • 2.46 Kb
You can Share it: