0

I am creating a searching system in a personal website. I have a database with a list of products, and for each product i would like to search it on the website by the requests module.

The main link is: "https://website.com/search/album?uid=1&q="

Example:

I am looking for Iphone 12 256 GB. The link should be: https://website.com/search/album?uid=1&q=Iphone+12+256+GB.

I've started just defing the main variable:

main_link = "https://website.com/search/album?uid=1&q="

product_name = "Iphone 12 256 GB"

product_name_to_search = product_name.split()


for product_word in product_name_to_search: 
   main_link + str(product_word)

Frankly, i dont know how to go on.

Abdul Gandal
  • 97
  • 1
  • 7

2 Answers2

1
product_name = product_name.replace(" ","+")
main_link = f"https://website.com/search/album?uid=1&q={product_name}"
gañañufla
  • 552
  • 2
  • 12
0

Try this:

main_link += '+'.join(product_name.split())

>>> print(main_link)
https://website.com/search/album?uid=1&q=Iphone+12+256+GB
IoaTzimas
  • 10,538
  • 2
  • 13
  • 30