I have made a script using beautifulsoup in order to get a price from a website. As a whole it works perfectly, cause it gives me the online price. But the problem is that :
- when I'm choosing another lg which is asked first it doesn't pay attention to the USER input and just works as it wishes to... now I want to know what is wrong with this, and another important thing is that:
- How can I Save the price with date in a text or CSV file...
- how can I re-run the app with a request of the user?
Here is my code:
#<div class="c-product__seller-price-raw js-price-value">۴,۵۹۵,۰۰۰ </div>
import requests
from bs4 import BeautifulSoup
html="https://www.digikala.com/product/dkp-1800630/%DA%AF%D9%88%D8%B4%DB%8C-%D9%85%D9%88%D8%A8%D8%A7%DB%8C%D9%84-%D8%B3%D8%A7%D9%85%D8%B3%D9%88%D9%86%DA%AF-%D9%85%D8%AF%D9%84-galaxy-a70-sm-a705fnds-%D8%AF%D9%88-%D8%B3%DB%8C%D9%85%DA%A9%D8%A7%D8%B1%D8%AA-%D8%B8%D8%B1%D9%81%DB%8C%D8%AA-128-%DA%AF%DB%8C%DA%AF%D8%A7%D8%A8%D8%A7%DB%8C%D8%AA"
user=input("Please select your language, English 'E' or Persian 'P': ")
def Persian_App():
request= requests.get(html)
content=request.content
soup=BeautifulSoup(content,"html.parser")
element=soup.find("div",{"class":"c-product__seller-price-raw js-price-value"})
print(" Gheymate Gooshie A70 Dar hale Hazer: ")
print(element.text.strip())
print("Anjam Shod!")
return ("")
def English_App():
request= requests.get(html)
content=request.content
soup=BeautifulSoup(content,"html.parser")
element=soup.find("div",{"class":"c-product__seller-price-raw js-price-value"})
print(" The Price of Samsung A70 Serie at the moment is: ")
print(element.text.strip())
print("Done")
return ("")
if user == "E" or "e":
print(English_App())
elif user == "P"or"p":
print(Persian_App())
else:
print("Please Enter a correct letter!")
pass
print(input("Press ANY Key to Exit!"))