Skip to content

Commit

Permalink
Added ability to search for the product or to enter their URL
Browse files Browse the repository at this point in the history
Added argument to the main function which will be the URL of the Product. However, the main is always called without any argument at first.
  • Loading branch information
yasharya2901 authored Nov 30, 2023
1 parent 9c3876b commit a670039
Showing 1 changed file with 50 additions and 36 deletions.
86 changes: 50 additions & 36 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,62 @@
from flipkart_scrapper import *
import sys

def main():
url = input("Enter the URL: ")
if "amazon" in url:
product_amazon = amazon(url)
product_amazon.print_product_info()

print("Would you like to search for the product automatically on Flipkart?")
print("Press 'y' to continue. Or Enter the Flipkart URL")
response = input("> ")

if response == "y" or response == "Y":
flipkart_link = flipkart.search_item(product_amazon.name)
if (flipkart_link == "exit"):
sys.exit("Exiting...")
else:
flipkart_link = response

product_flipkart = flipkart(flipkart_link)
product_flipkart.print_product_info()
def main(*args):
if args:
response = args[0]
else:
response = input("Enter the product name or URL: ")
if "http" in response:
url = response
if "amazon" in url:
product_amazon = amazon(url)
product_amazon.print_product_info()

print("Would you like to search for the product automatically on Flipkart?")
print("Press 'y' to continue. Or Enter the Flipkart URL")
response = input("> ")

elif "flipkart" in url:
product_flipkart = flipkart(url)
product_flipkart.print_product_info()
if response == "y" or response == "Y":
flipkart_link = flipkart.search_item(product_amazon.name)
if (flipkart_link == "exit"):
sys.exit("Exiting...")
else:
flipkart_link = response

product_flipkart = flipkart(flipkart_link)
product_flipkart.print_product_info()

print("Would you like to search for the product automatically on Amazon?")
print("Press 'y' to continue. Or Enter the Amazon URL")
response = input("> ")

if response == "y" or response == "Y":
amazon_link = amazon.search_item(product_flipkart.name)
if (amazon_link == "exit"):
sys.exit("Exiting...")
else:
amazon_link = response
elif "flipkart" in url:
product_flipkart = flipkart(url)
product_flipkart.print_product_info()

print("Would you like to search for the product automatically on Amazon?")
print("Press 'y' to continue. Or Enter the Amazon URL")
response = input("> ")

if response == "y" or response == "Y":
amazon_link = amazon.search_item(product_flipkart.name)
if (amazon_link == "exit"):
sys.exit("Exiting...")
else:
amazon_link = response

product_amazon = amazon(amazon_link)
product_amazon.print_product_info()

product_amazon = amazon(amazon_link)
product_amazon.print_product_info()

else:
print("Website Not Supported")
else:
print("Website Not Supported")

platform = input("Where would you like to search that product? Amazon or Flipkart? ")
if platform == "amazon" or platform == "Amazon":
main(amazon.search_item(response))

elif platform == "flipkart" or platform == "Flipkart":
main(flipkart.search_item(response))

else:
sys.exit("Platform not supported.")
return 0

if __name__ == '__main__':
Expand Down

0 comments on commit a670039

Please sign in to comment.