[text] L

Viewer

  1. import requests
  2.  
  3. # URL for the main action
  4. url = 'https://toolkit.tesco.com/partner/reports/'
  5.  
  6. # Define options for each category/subcategory
  7. Country = ['UK', 'ROI']
  8. Report_type = ['Sales and stock', 'Range conformance', 'Promotional funding', 'Auto sales out retro deals', 'Fulfilment fee', 'Performance summary', 'Cost price amendments', 'Purchase order amendments']
  9. Product_subgroup = ['All product subgroups']
  10. Products = ['All products']
  11. 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']
  12. Time_period = ['Last full week (Wk 08)']
  13.  
  14. # Iterate over combinations of options
  15. for country in Country:
  16.     for report_type in Report_type:
  17.         for product_subgroup in Product_subgroup:
  18.             for product in Products:
  19.                 for view in View:
  20.                     for time_period in Time_period:
  21.                         # Send request to select options
  22.                         options_data = {
  23.                             'Country': country,
  24.                             'Report type': report_type,
  25.                             'Product subgroup': product_subgroup,
  26.                             'Product': product,
  27.                             'View': view,
  28.                             'Time period': time_period
  29.                         }
  30.                         try:
  31.                             response = requests.post(url, data=options_data)
  32.                             response.raise_for_status()  # Raise exception for 4xx or 5xx errors
  33.                             # Process the response as needed
  34.                             print(f"Options selected: {options_data}")
  35.                             print("Response:", response.text)
  36.                         except requests.exceptions.HTTPError as err:
  37.                             print(f"An error occurred: {err}")

Editor

You can edit this paste and save as new:


File Description
  • L
  • Paste Code
  • 25 Apr-2024
  • 1.91 Kb
You can Share it: