Skip to content

Commit 8870a61

Browse files
authored
Add files via upload
1 parent d7b610a commit 8870a61

3 files changed

+86
-17
lines changed

Flipkart_Price_finder.py

+29-15
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,47 @@
33
#Necessary Modules
44
import bs4 as bs
55
import urllib.request
6-
7-
6+
import os
7+
import Slack_Push_Notification as Slack
8+
global msg
89
def flipkart_price(url):
910
''' Prints the price of the Items' URLs provided as argument.'''
1011
source = urllib.request.urlopen(url).read()
1112
soup = bs.BeautifulSoup(source, 'lxml')
12-
13+
global msg
1314
#Getting the name of the item
1415
item_name = soup.find('p').text
1516

1617
#Getting the price of item
1718
price = soup.find('div', class_ = '_1vC4OE _3qQ9m1').text
1819

19-
print("Current price of \"{}\" is: Rs. {}/-".format(item_name, price))
20+
msg = "Current price of \"{}\" is: Rs. {}/-".format(item_name, price)
21+
print(msg)
2022

2123
#List of URLs of items on Flipkart.
22-
my_list = ['https://www.flipkart.com/samsung-galaxy-s9-plus-coral-blue-64-gb/p/itmf33a6qhrkyth3?pid=MOBF2VWVHDAZRQGH&srno=b_1_1&otracker=hp_omu_Top%2BOffers%2BOn%2BMobiles_3_7.dealCard.OMU_YZLF8ZJ051G3_7&otracker1=hp_omu_PINNED_neo%2Fmerchandising_Top%2BOffers%2BOn%2BMobiles_NA_dealCard_cc_3_NA_view-all_7&lid=LSTMOBF2VWVHDAZRQGHCF6TXA&fm=neo%2Fmerchandising&iid=6ef955c2-b372-4b94-92ca-3b6131ecb748.MOBF2VWVHDAZRQGH.SEARCH&ppt=browse&ppn=browse&ssid=gtpkjmcy9c0000001570971060174',
23-
'https://www.flipkart.com/redmi-note-7s-astro-moonlight-white-32-gb/p/itm5e8bac3bcf4c4?pid=MOBFJFZDP9R3Z7YK&lid=LSTMOBFJFZDP9R3Z7YKQJSH2X&marketplace=FLIPKART&srno=b_1_1&otracker=hp_omu_Top%2BOffers_2_3.dealCard.OMU_88559FM66S42_3&otracker1=hp_omu_PINNED_neo%2Fmerchandising_Top%2BOffers_NA_dealCard_cc_2_NA_view-all_3&fm=neo%2Fmerchandising&iid=2af1c4be-4b89-454e-95ed-09de21c5962f.MOBFJFZDP9R3Z7YK.SEARCH&ppt=browse&ppn=browse&ssid=s8tyw8t4fk0000001570970986200',
24-
'https://www.flipkart.com/sherlock-holmes-complete-novels-stories-volume/p/itmf3jbqsvdktrsn?pid=9780553212419&lid=LSTBOK9780553212419QAWDRK&marketplace=FLIPKART&srno=s_1_13&otracker=AS_QueryStore_OrganicAutoSuggest_0_15&fm=SEARCH&iid=7fc6db9f-ec7d-42c1-b9e8-ba0fde32b658.9780553212419.SEARCH&ppt=Homepage&ppn=Homepage&ssid=esl8lszfjk0000001552810927096&qH=e717ef139779e544',
25-
'https://www.flipkart.com/moto-z2-play-lunar-gray-64-gb/p/itmevt7xuk6xv3e7?pid=MOBEU9WRFZNAP2MJ&srno=s_1_4&otracker=search&lid=LSTMOBEU9WRFZNAP2MJVK3CZ5&fm=SEARCH&iid=a3be6899-5ef4-43a9-9dcd-ba4a059f63b1.MOBEU9WRFZNAP2MJ.SEARCH&ppt=SearchPage&ppn=Search&ssid=mmswc1u8cg0000001552811023594&qH=de88b155ee0c683f',
26-
'https://www.flipkart.com/highlander-men-s-checkered-casual-black-grey-shirt/p/itmfekrxkpxpdgg8?pid=SHTEZG79ZQGTFHZH&lid=LSTSHTEZG79ZQGTFHZHR9ENLK&marketplace=FLIPKART&srno=b_1_5&otracker=nmenu_sub_Men_0_Shirts&fm=neo%2Fmerchandising&iid=17c3cbcd-70f7-417c-b5a0-8453205cff2a.SHTEZG79ZQGTFHZH.SEARCH&ppt=StoreBrowse&ppn=Store&ssid=qi0y9l3wkw0000001552811061578',
27-
'https://www.flipkart.com/metronaut-men-solid-casual-blue-shirt/p/itmf5xtgj8h8syw7?pid=SHTF5XTGHYNPUED9&lid=LSTSHTF5XTGHYNPUED95AHKNN&marketplace=FLIPKART&srno=b_1_15&otracker=nmenu_sub_Men_0_Shirts&fm=neo%2Fmerchandising&iid=0ce9785f-4582-400d-a2a6-c62d2cb5296e.SHTF5XTGHYNPUED9.SEARCH&ppt=StoreBrowse&ppn=Store',
28-
'https://www.flipkart.com/jbl-t500-bluetooth-headset-mic/p/itmfa2ppt5rnagmz?pid=ACCFA2PPHMFS853G&lid=LSTACCFA2PPHMFS853GJ0MJDC&marketplace=FLIPKART&fm=personalisedRecommendation%2Fp2p-same&iid=R%3As%3Bp%3AACCEXBNK9ZZMUN4Y%3Bpt%3Ahp%3Buid%3Acc5c75ee-873e-7918-14ee-c15a54cd7e54%3B.ACCFA2PPHMFS853G.LSTACCFA2PPHMFS853GJ0MJDC&otracker=hp_reco_You%2BMay%2BLike_2_JBL%2BT500%2BBluetooth%2BHeadset%2Bwith%2BMic_ACCFA2PPHMFS853G.LSTACCFA2PPHMFS853GJ0MJDC_3&otracker1=hp_reco_WHITELISTED_personalisedRecommendation%2Fp2p-same_You%2BMay%2BLike_DESKTOP_HORIZONTAL_productCard_cc_2_NA_3&cid=ACCFA2PPHMFS853G.LSTACCFA2PPHMFS853GJ0MJDC',
29-
'https://www.flipkart.com/adidas-solonyx-2-0-m-running-shoes-men/p/itmf3xmjyg7mggry?pid=SHOEVMGGZJGEJZGA&lid=LSTSHOEVMGGZJGEJZGAOCO5LD&marketplace=FLIPKART&fm=personalisedRecommendation%2Fp2p-same&iid=R%3As%3Bp%3ASHOF7G8FYPMJTE45%3Bpt%3Ahp%3Buid%3Af50ba4c4-e9f0-25f4-a824-23a9151b1bf6%3B.SHOEVMGGZJGEJZGA.LSTSHOEVMGGZJGEJZGAOCO5LD&otracker=hp_reco_Suggested%2BItems_5_ADIDAS%2BSOLONYX%2B2.0%2BM%2BRunning%2BShoes%2BFor%2BMen_SHOEVMGGZJGEJZGA.LSTSHOEVMGGZJGEJZGAOCO5LD_4&otracker1=hp_reco_WHITELISTED_personalisedRecommendation%2Fp2p-same_Suggested%2BItems_DESKTOP_HORIZONTAL_productCard_cc_5_NA_4&cid=SHOEVMGGZJGEJZGA.LSTSHOEVMGGZJGEJZGAOCO5LD',
30-
'https://www.flipkart.com/sony-dsx-a110u-media-receiver-usb-car-stereo/p/itmf2gd8rfekwta8?pid=CDPF2G9VEGBRSPP8&lid=LSTCDPF2G9VEGBRSPP8UTOWZ4&marketplace=FLIPKART&srno=b_1_1&otracker=browse&fm=personalisedRecommendation%2Fp2p-same&iid=4a04836c-ad4f-4a98-adbd-6d7b1ef85a76.CDPF2G9VEGBRSPP8.SEARCH&ppt=Homepage&ppn=Homepage&ssid=2i37pt0l740000001552811138846',
31-
'https://www.flipkart.com/philips-9-w-round-b22-led-bulb/p/itme6zzs5rrzhbea?pid=BLBE6ZZS3GBMSRFG&lid=LSTBLBE6ZZS3GBMSRFGBL31A0&marketplace=FLIPKART&srno=b_1_7&otracker=nmenu_sub_Home%20%26%20Furniture_0_LED%20%26%20CFL&fm=personalisedRecommendation%2Fp2p-same&iid=e7c47080-4fda-4d11-a45d-df065a7a4dac.BLBE6ZZS3GBMSRFG.SEARCH&ppt=Homepage&ppn=Homepage&ssid=4m52zd9rs00000001552811159233',
32-
'https://www.flipkart.com/sandisk-ultra-dual-drive-m3-0-32-gb-otg/p/itmf3qyazyfgaf48?pid=ACCENUZA28X2PQ4G&lid=LSTACCENUZA28X2PQ4G2I1L5J&marketplace=FLIPKART&srno=s_1_2&otracker=search&fm=SEARCH&iid=9f70010f-2eb5-4633-abb2-9116bdb30ed8.ACCENUZA28X2PQ4G.SEARCH&ppt=SearchPage&ppn=Search&ssid=c8pc94pu9c0000001552811191243&qH=88442f18ff77821c']
24+
my_list = ['https://www.flipkart.com/redmi-8-onyx-black-64-gb/p/itmaf669d074ff27',
25+
]
3326

3427
for i in my_list:
3528
flipkart_price(i)
29+
30+
31+
'''
32+
url = 'https://www.flipkart.com/adidas-adiray-m-running-shoes-men/p/itmf7g8fxnxydsuc?pid=SHOF7G8FYPMJTE45&lid=LSTSHOF7G8FYPMJTE458RA8CT&marketplace=FLIPKART&spotlightTagId=TrendingId_osp%2Fcil&srno=b_1_1&otracker=hp_omu_Deals%2Bof%2Bthe%2BDay_1_ISKSFOA9MJUY_0&fm=neo%2Fmerchandising&iid=633f9421-e711-4aab-8d4b-900ac8af91f8.SHOF7G8FYPMJTE45.SEARCH&ppt=StoreBrowse&ppn=Store&ssid=kkwtb7mn5c0000001552810060372'
33+
34+
source = urllib.request.urlopen(url).read()
35+
soup = bs.BeautifulSoup(source, 'lxml')
36+
37+
getting the name of item
38+
item_name = soup.find('p').text
39+
40+
getting the price
41+
price = soup.find('div', class_ = '_1vC4OE _3qQ9m1').text
42+
43+
print("Current price of \"{}\" is: Rs. {}/-".format(item_name, price))
44+
45+
'''
46+
# To get the current file name: os.path.basename(__file__)
47+
# Entire Directory: __file__
48+
49+
Slack.slack_message(msg, __file__)

Online Coding Platform Rating Tracker.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@
9494
spoj_rank,
9595
ib_score)
9696

97-
Slack.slack_message(msg)
98-
print('\nPush Notification Successfully Sent.\n')
97+
Slack.slack_message(msg, __file__)
98+
9999
#print('\n**** Message Preview: **** \n{}'.format(msg))

Weather_Update_Hyderabad.py

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#Weather_Update - Hyderabad
2+
3+
#Necessary Modules
4+
from prettytable import PrettyTable
5+
import requests
6+
import bs4 as bs
7+
import datetime
8+
import sys
9+
import os
10+
import Slack_Push_Notification as Slack
11+
#import Balloon_tip as Bt
12+
13+
#Dictionary to store the Weather Details. Date as Keys and details as the value stored as a list.
14+
weather_details = {}
15+
16+
#Current Date
17+
curr_date = datetime.datetime.now().strftime("%d-%b-%Y")
18+
date_1 = datetime.datetime.strptime(curr_date, "%d-%b-%Y")
19+
20+
#Using a browser Agent
21+
headers = {"User-agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36"}
22+
area = 'hyderabad'
23+
24+
#Getting the webpage of the URL
25+
url = 'https://www.timeanddate.com/weather/india/' + area + '/ext'
26+
response = requests.get(url, headers = headers)
27+
html = response.text
28+
29+
#Extracting the necessary information
30+
soup = bs.BeautifulSoup(html, 'lxml')
31+
temp = soup.find('tbody')
32+
33+
#Looping and extracting the Information about weather.
34+
for i in range(2):
35+
end_date = date_1 + datetime.timedelta(days=i)
36+
try:
37+
temperature = temp.select_one("tr:nth-of-type(" + str(i+1) + ")").select_one("td:nth-of-type(2)").text
38+
weather_details[end_date.strftime("%d-%b-%Y")] = [temperature]
39+
weather_details[end_date.strftime("%d-%b-%Y")].append(temp.select_one("tr:nth-of-type(" + str(i+1) + ")").select_one("td:nth-of-type(3)").text)
40+
weather_details[end_date.strftime("%d-%b-%Y")].append(temp.select_one("tr:nth-of-type(" + str(i+1) + ")").select_one("td:nth-of-type(4)").text)
41+
except AttributeError:
42+
print('Weather Forecast NOT AVAILABLE for this Location. Please Enter a popular location.')
43+
sys.exit(8)
44+
45+
46+
#This Part of code is used to show a desktop notification. It only shows the current day weather for the choosen location.
47+
notif = 'Today\'s Weather Update - ' + area.title() + '\nMin/Max Temp: {}\nWeather: {}\nFeels Like: {}'.format(weather_details[curr_date][0], weather_details[curr_date][1],weather_details[curr_date][2])
48+
49+
#Desktop Notification
50+
#Bt.balloon_tip(notif)
51+
52+
#Slack Notification
53+
Slack.slack_message(notif, __file__)
54+
print(notif)
55+

0 commit comments

Comments
 (0)