Tuesday, 22 October 2019

Python scripting to find the less price of a product in flipkart?

i did this in Visual studio

flipkart.py

import requests
from bs4 import Beautifulsoup
import smtplib
import time

URL='https://www.flipkart.com/samsung-860-evo-500-gb-laptop-desktop-internal-solid-state-drive-mz-76e500bw/p/itmf29fsy7vd2rrs?pid=IHDF29FSXVK2XCNC&lid=LSTIHDF29FSXVK2XCNCZOBQMG&marketplace=FLIPKART&spotlightTagId=BestsellerId_6bo%2Fjdy%2Fdus&srno=s_1_1&otracker=AS_QueryStore_OrganicAutoSuggest_0_14_na_na_pr&otracker1=AS_QueryStore_OrganicAutoSuggest_0_14_na_na_pr&fm=SEARCH&iid=05be7843-7804-4652-9201-19c258483fd9.IHDF29FSXVK2XCNC.SEARCH&ppt=sp&ppn=sp&ssid=i63km5673k0000001574335050122&qH=af4522800d2749f5'

# in flipkart you type any of the product name copy link

headers={"user_Agent":'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/.0.04.97 Safari/537.36'}

# type in google my user agent
page=requests.get(url,headers=headers)
soup=Beautifulsoup(page.content,'html.parser')

#print(soup.prettify())

title=soup.find(id="Product Title").get_text()
price=soup.Find(id="price block_our price").get_text()

converted_price=float(price[0:5])
print (converted_price)

if(converted_price<5000):
    send_mail()
    print (converted_price)
    print (title.strip())
if(converted_price>6000):
    send_mail()
def send_mail():
server=smtplib.SMTP('smtp.gmail.com',567)
server.ehlo()  #Elho command tells us email server is sending a email to another
server.starttls
server.ehlo()
server.login('prathyusha@gmail.com','generated password')

#google two step verification (you have to enable)
#google App Passwords
#generate the password

subject='price fell down'

body='check the flipkart link https://www.flipkart.com/samsung-860-evo-500-gb-laptop-desktop-internal-solid-state-drive-mz-76e500bw/p/itmf29fsy7vd2rrs?pid=IHDF29FSXVK2XCNC&lid=LSTIHDF29FSXVK2XCNCZOBQMG&marketplace=FLIPKART&spotlightTagId=BestsellerId_6bo%2Fjdy%2Fdus&srno=s_1_1&otracker=AS_QueryStore_OrganicAutoSuggest_0_14_na_na_pr&otracker1=AS_QueryStore_OrganicAutoSuggest_0_14_na_na_pr&fm=SEARCH&iid=05be7843-7804-4652-9201-19c258483fd9.IHDF29FSXVK2XCNC.SEARCH&ppt=sp&ppn=sp&ssid=i63km5673k0000001574335050122&qH=af4522800d2749f5      #first url you have to paste https://www.amazon.de/-----'

msg=f"subject:{subject}\n\n {body}"
server.send_mail(
         'pratyusha@gmail.com'
'anu@gmail.com'
        msg
)
print ('Hey Email has been sent!')
server.quit()
while(True):
check_price()
time.sleep(60 * 60)

Streamlining the usage of GITHUB

Streamlining the usage of Github with Commands 1. Start a new git repository under one directory locally In this step, we need to bui...