
"""simple docstring"""







from itertools import zip_longest

import requests
from bsa import BeautifulSoup
from pandas import DataFrame
def     __lowerCAmelCase				(_UpperCamelCase = "laptop"		):
	__lowerCAmelCase			:						Any									=      F"https://www.amazon.in/laptop/s?k={product}"
	__lowerCAmelCase			:						Dict									=      {
	    'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36\n        (KHTML, like Gecko)Chrome/44.0.2403.157 Safari/537.36',
	    'Accept-Language': 'en-US, en;q=0.5',
	}
	__lowerCAmelCase			:						List[Any]									=      BeautifulSoup(requests.get(_UpperCamelCase       ,  headers=_UpperCamelCase		).text		)
	# Initialize a Pandas dataframe with the column titles
	__lowerCAmelCase			:						Union[str, Any]									=      DataFrame(
	    columns=[
	        'Product Title',
	        'Product Link',
	        'Current Price of the product',
	        'Product Rating',
	        'MRP of the product',
	        'Discount',
	    ]		)
	# Loop through each entry and store them in the dataframe
	for item, _ in zip_longest(
	    soup.find_all(
	        'div'       ,  attrs={'class': 's-result-item', 'data-component-type': 's-search-result'}       ,  )       ,  soup.find_all('div'       ,  attrs={'class': 'a-row a-size-base a-color-base'}		)       ,  ):
		try:
			__lowerCAmelCase			:						str									=      item.ha.text
			__lowerCAmelCase			:						Tuple									=      'https://www.amazon.in/' + item.ha.a['href']
			__lowerCAmelCase			:						Optional[Any]									=      item.find('span'       ,  attrs={'class': 'a-offscreen'}		).text
			try:
				__lowerCAmelCase			:						List[Any]									=      item.find('span'       ,  attrs={'class': 'a-icon-alt'}		).text
			except AttributeError:
				__lowerCAmelCase			:						List[str]									=      'Not available'
			try:
				__lowerCAmelCase			:						Any									=      (
				    '₹'
				    + item.find(
				        'span'       ,  attrs={'class': 'a-price a-text-price'}		).text.split('₹'		)[1]
				)
			except AttributeError:
				__lowerCAmelCase			:						Optional[int]									=      ''
			try:
				__lowerCAmelCase			:						List[Any]									=      float(
				    (
				        (
				            float(product_mrp.strip('₹'		).replace(','       ,  ''		)		)
				            - float(product_price.strip('₹'		).replace(','       ,  ''		)		)
				        )
				        / float(product_mrp.strip('₹'		).replace(','       ,  ''		)		)
				    )
				    * 100		)
			except ValueError:
				__lowerCAmelCase			:						str									=      float('nan'		)
		except AttributeError:
			pass
		__lowerCAmelCase			:						str									=      [
		    product_title,
		    product_link,
		    product_price,
		    product_rating,
		    product_mrp,
		    discount,
		]
	__lowerCAmelCase			:						List[Any]									=      ' '
	__lowerCAmelCase			:						Tuple									=      ' '
	data_frame.index += 1
	return data_frame


if __name__ == "__main__":
							lowerCamelCase__   					=		"""headphones"""
							get_amazon_product_data(product).to_csv(f'Amazon Product Data for {product}.csv')



"""simple docstring"""



def   __lowerCAmelCase						(						lowercase  :  List[str]						,							lowercase  :  Union[str, Any]						,							lowercase  :  List[str]						,							lowercase  :  Tuple						,							lowercase  :  List[Any]						,							lowercase  :  int )	->						List[Any]:


    """simple docstring"""





    if index == r:
        for j in range(lowercase ):
            print(data[j]						,							end=" " )
        print(" " )
        return
    #  When no more elements are there to put in data[]
    if i >= n:
        return
    # current is included, put next at next location
    snake_case    :      Union[str, Any]      					=    arr[i]
    combination_util(lowercase						,							lowercase						,							lowercase						,							index + 1						,							lowercase						,							i + 1 )
    # current is excluded, replace it with
    # next (Note that i+1 is passed, but
    # index is not changed)
    combination_util(lowercase						,							lowercase						,							lowercase						,							lowercase						,							lowercase						,							i + 1 )
    # The main function that prints all combinations
    # of size r in arr[] of size n. This function
    # mainly uses combinationUtil()







def   __lowerCAmelCase						(						lowercase  :  Any						,							lowercase  :  Union[str, Any]						,							lowercase  :  Optional[int] )	->						List[Any]:


    """simple docstring"""





    snake_case    :      Any      					=    [0] * r
    # Print all combination using temporary array 'data[]'
    combination_util(lowercase						,							lowercase						,							lowercase						,							0						,							lowercase						,							0 )


if __name__ == "__main__":
  # Driver code to check the function above
  __snake_case   			=    [10, 20, 30, 40, 50]
  print_combination(arr, len(arr), 3)
  # This code is contributed by Ambuj sahu





