Skip to content

Commit 3bea6dd

Browse files
committed
merge~1
1 parent 4231b29 commit 3bea6dd

File tree

23 files changed

+346
-233
lines changed

23 files changed

+346
-233
lines changed

.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length = 100
3+
exclude = .git,__pycache__,.venv,venv,build,dist,.idea,*.xml,*.iml,*.csv,*.jpg,*.png,Output
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Python package
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
python-version: ["3.9", "3.10", "3.11"]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v3
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
python -m pip install flake8 pytest
30+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31+
32+
- name: Lint with flake8
33+
run: |
34+
echo "🔍 Checking for null bytes in Python files..."
35+
if grep -rl $'\x00' --include="*.py" .; then
36+
echo "❌ Found null bytes in Python source files!"
37+
exit 1
38+
fi
39+
40+
echo "✅ Running flake8 only on Python files..."
41+
# Stop the build on syntax errors/undefined names
42+
flake8 --count --select=E9,F63,F7,F82 --show-source --statistics
43+
# Style checks (won't fail build)
44+
flake8 --count --exit-zero --max-complexity=10 --max-line-length=100 --statistics
45+
46+
- name: Test with pytest
47+
run: |
48+
pytest

API Project/date_time api.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import requests
2+
import datetime
3+
my_latitude = 20.593683
4+
my_longitude = 78.962883
5+
6+
parameters= {
7+
"lat":my_latitude,
8+
"lng":my_longitude,
9+
"formatted":0,
10+
"tzid":"Asia/Kolkata"
11+
}
12+
13+
response = requests.get("https://api.sunrise-sunset.org/json",params=parameters)
14+
response.raise_for_status()
15+
data=response.json()
16+
print(data["results"]["sunset"])
17+
a=datetime.datetime.now()
18+
print(a)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
import requests
3+
import smtplib
4+
from datetime import datetime
5+
6+
my_latitude=22.700720
7+
my_longitude=75.934700
8+
9+
10+
def iss_overhead():
11+
response = requests.get(url="http://api.open-notify.org/iss-now.json")
12+
data=response.json()
13+
current_latitude=float(data["iss_position"]["latitude"])
14+
current_longitude=float(data["iss_position"]["longitude"])
15+
16+
if my_longitude+5==current_longitude <=my_longitude-5 and my_latitude+5==current_latitude<=-5:
17+
return True
18+
19+
parameters = {
20+
"lat": MY_LAT,
21+
"lng": MY_LONG,
22+
"formatted": 0,
23+
}
24+
25+
response = requests.get("https://api.sunrise-sunset.org/json", params=parameters)
26+
response.raise_for_status()
27+
data = response.json()
28+
sunrise = int(data["results"]["sunrise"].split("T")[1].split(":")[0])
29+
sunset = int(data["results"]["sunset"].split("T")[1].split(":")[0])
30+
31+
time_now = datetime.now()
32+
33+
34+
my_email = "shubmrj@gmail.com"
35+
password = "vcwsqfzbmgjpgjkx"
36+
37+
with smtplib.SMTP("smtp.gmail.com", port=587) as connection:
38+
connection.starttls()
39+
connection.login(user=my_email, password=password)
40+
41+
connection.sendmail(
42+
from_addr=my_email,
43+
to_addrs="srnwda@gmail.com",
44+
msg="Subject:ISIS\n\n Hello , ISIS on your head. "
45+
)
46+
print("Successful Executed")
47+
48+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import requests
2+
from datetime import datetime
3+
4+
MY_LAT = 51.507351 # Your latitude
5+
MY_LONG = -0.127758 # Your longitude
6+
7+
response = requests.get(url="http://api.open-notify.org/iss-now.json")
8+
response.raise_for_status()
9+
data = response.json()
10+
11+
iss_latitude = float(data["iss_position"]["latitude"])
12+
iss_longitude = float(data["iss_position"]["longitude"])
13+
14+
#Your position is within +5 or -5 degrees of the ISS position.
15+
16+
17+
parameters = {
18+
"lat": MY_LAT,
19+
"lng": MY_LONG,
20+
"formatted": 0,
21+
}
22+
23+
response = requests.get("https://api.sunrise-sunset.org/json", params=parameters)
24+
response.raise_for_status()
25+
data = response.json()
26+
sunrise = int(data["results"]["sunrise"].split("T")[1].split(":")[0])
27+
sunset = int(data["results"]["sunset"].split("T")[1].split(":")[0])
28+
29+
time_now = datetime.now()
30+
31+
#If the ISS is close to my current position
32+
# and it is currently dark
33+
# Then send me an email to tell me to look up.
34+
# BONUS: run the code every 60 seconds.
35+
36+
37+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import requests
2+
3+
# from main import latitude
4+
5+
response = requests.get(url="http://api.open-notify.org/iss-now.json")
6+
7+
data=response.json()
8+
9+
current_latitude=data["iss_position"]["latitude"]
10+
current_longitude=data["iss_position"]["longitude"]
11+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from tkinter import *
2+
import requests
3+
4+
def get_quote():
5+
response=requests.get("https://api.kanye.rest/")
6+
data = response.json()
7+
# print(response)
8+
# a=data["quote"]
9+
canvas.itemconfig(quote_text,text=data["quote"])
10+
11+
12+
13+
window = Tk()
14+
window.title("Kanye Says...")
15+
window.config(padx=50, pady=50)
16+
17+
canvas = Canvas(width=300, height=414)
18+
background_img = PhotoImage(file="background.png")
19+
canvas.create_image(150, 207, image=background_img)
20+
quote_text = canvas.create_text(150, 207, text="xyz", width=250, font=("Arial", 30, "bold"), fill="white")
21+
canvas.grid(row=0, column=0)
22+
canvas.itemconfig(quote_text,text=get_quote())
23+
24+
kanye_img = PhotoImage(file="kanye.png")
25+
kanye_button = Button(image=kanye_img, highlightthickness=0, command=get_quote)
26+
kanye_button.grid(row=1, column=0)
27+
28+
29+
30+
window.mainloop()

API Project/main.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import requests
2+
3+
response=requests.get("http://api.open-notify.org/iss-now.json")
4+
5+
# if response.status_code==404:
6+
# raise Exception("That Resource Does not Exist.")
7+
# elif response.status_code==401:
8+
# raise Exception("You are not Authorize to access this data.")
9+
response.raise_for_status()
10+
11+
data= response.json()
12+
13+
longitude = data["iss_position"]["longitude"]
14+
latitude = data["iss_position"]["latitude"]
15+
iss_position =(longitude,latitude)
16+
17+
print(iss_position)

Amazon Price Tracker/main.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from bs4 import BeautifulSoup
2+
import requests
3+
import os
4+
import smtplib
5+
import datetime
6+
from dotenv import load_dotenv
7+
8+
load_dotenv()
9+
date=datetime.datetime.now().strftime("%d/%m/%Y")
10+
11+
# static url to get the price
12+
url="https://appbrewery.github.io/instant_pot/"
13+
14+
# live url to get the price which is dyanmaic hard to parse so i take the static url
15+
live_url = "https://www.amazon.com/dp/B075CYMYK6?psc=1&ref_=cm_sw_r_cp_ud_ct_FM9M699VKHTT47YD50Q6"
16+
17+
# ADD header for look my requests more realistics rather than ai generated
18+
# requests.get(url, params=None, headers=None, cookies=None, auth=None, timeout=None) this is params of requests
19+
20+
# header
21+
22+
header={
23+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
24+
"Accept-Encoding": "gzip, deflate, br, zstd",
25+
"Accept-Language": "en-US,en;q=0.9,hi;q=0.8",
26+
"Dnt": "1",
27+
"Priority": "u=0, i",
28+
"Sec-Ch-Ua": '"Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141"',
29+
"Sec-Ch-Ua-Mobile": "?0",
30+
"Sec-Ch-Ua-Platform": "Windows",
31+
"Sec-Fetch-Dest": "document",
32+
"Sec-Fetch-Mode": "navigate",
33+
"Sec-Fetch-Site": "cross-site",
34+
"Sec-Fetch-User": "?1",
35+
"Upgrade-Insecure-Requests": "1",
36+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36",
37+
}
38+
39+
response=requests.get(url=live_url,headers=header)
40+
soup=BeautifulSoup(response.text,"html.parser")
41+
42+
# check whether what kind of requests i get
43+
print(soup.prettify()[:2000])
44+
45+
price=soup.find(class_="a-price-whole").get_text()
46+
47+
price_without_currency = price.split("$")[1]
48+
49+
price_as_float=float(price_without_currency)
50+
51+
print(price_as_float)
52+
53+
54+
# Send Email if price less than 100
55+
if price_as_float<100:
56+
my_email = os.getenv("EMAIL")
57+
password = os.getenv("PASSWORD")
58+
59+
with smtplib.SMTP("smtp.gmail.com",port=587) as connection:
60+
connection.starttls()
61+
connection.login(user=my_email,password=password)
62+
63+
connection.sendmail(
64+
from_addr=my_email,
65+
to_addrs="srnwda@gmail.com",
66+
msg=f"Subject:Amazon Price Alert\n\n{price}\n{live_url}\n at the time of {date}"
67+
)
68+
69+
# you can try with static becuase live might not run

Automate Spotify Playlist/hint.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from bs4 import BeautifulSoup
2+
import requests
3+
4+
response = requests.get("https://appbrewery.github.io/news.ycombinator.com/")
5+
yc_web_page = response.text
6+
7+
soup = BeautifulSoup(yc_web_page, 'html.parser')
8+
9+
# Get all article links
10+
articles = soup.find_all(name='a', class_='storylink')
11+
12+
article_text = []
13+
article_url = []
14+
15+
for article in articles:
16+
text = article.get_text()
17+
article_text.append(text)
18+
url = article.get("href")
19+
article_url.append(url)
20+
21+
# Get upvotes
22+
article_upvote = [int(score.getText().split()[0]) for score in soup.find_all(name='span', class_="score")]
23+
24+
print(article_text)
25+
print(article_url)
26+
print(article_upvote)
27+
max_val=article_upvote.index(max(article_upvote))
28+
print("\n")
29+
print("Print the maximum score of article upvote")
30+
print(f"Article Text : {article_text[max_val]} , With url link : {article_url[max_val]} with total upvotes : {article_upvote[max_val]}")
31+
32+
# for split value of upvote
33+
# no_upvote = []
34+
#
35+
# for i in range(len(article_upvote)):
36+
# article_upvote1 = article_upvote[0].split(' ')[0]
37+
# no_upvote.append(article_upvote1)
38+
# print(no_upvote)

0 commit comments

Comments
 (0)