diff --git a/Day52/instagram.py b/Day52/instagram.py new file mode 100644 index 0000000..a9e3e97 --- /dev/null +++ b/Day52/instagram.py @@ -0,0 +1,86 @@ +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.chrome.options import Options +from selenium.webdriver.common.keys import Keys + +import time + +chrome_driver_path = "/home/ali/Development/chromedriver" +chrome_options = Options() +chrome_options.add_experimental_option("detach", True) +driver = webdriver.Chrome( + executable_path=chrome_driver_path, options=chrome_options) +driver.get("https://www.instagram.com/accounts/login/") +driver.maximize_window() +time.sleep(3) +turn_off_notifications = driver.find_element(By.XPATH, '/html/body') +turn_off_notifications.send_keys( + Keys.TAB + Keys.TAB + Keys.TAB + Keys.TAB + Keys.TAB + Keys.TAB + Keys.ENTER) + +username = driver.find_element(by=By.NAME, value="username") +password = driver.find_element(by=By.NAME, value="password") +username.send_keys("fsfsfs") +password.send_keys("fsfsfs") +time.sleep(2) +login = driver.find_element( + by=By.XPATH, value='/html/body/div[2]/div/div/div[1]/div/div/div/div[1]/section/main/div/div/div[1]/div[2]/form/div/div[3]/button') +time.sleep(3) +login.click() +time.sleep(3) +notification = driver.find_element(By.XPATH, '/html/body') +notification.send_keys(Keys.TAB + Keys.TAB + Keys.ENTER) +time.sleep(3) +# notification = driver.find_element(By.XPATH, '/html/body') +# notification.send_keys(Keys.TAB + Keys.TAB + Keys.ENTER) +# time.sleep(3) +# notification = driver.find_element(By.XPATH, '/html/body') +# notification.send_keys(Keys.TAB + Keys.TAB + Keys.ENTER) +# time.sleep(3) +select_profile = driver.find_element( + by=By.XPATH, value='/html/body/div[2]/div/div/div[1]/div/div/div/div[1]/div[1]/div[2]/section/main/div[1]/section/div[3]/div[1]/div/div/div[2]/div[1]/div/div/a') +select_profile.click() +time.sleep(4) +select_followers = driver.find_element( + by=By.XPATH, value='/html/body/div[2]/div/div/div[1]/div/div/div/div[1]/div[1]/div[2]/section/main/div/header/section/ul/li[2]/a/div') +time.sleep(2) +select_followers.click() +time.sleep(4) +modal = driver.find_element( + by=By.XPATH, value='/html/body/div[2]/div/div/div[2]/div/div/div[1]/div/div[2]/div/div/div/div/div[2]/div/div/div[2]') +time.sleep(5) +for i in range(10): + driver.execute_script( + "arguments[0].scrollTop = arguments[0].scrollHeight", modal) + time.sleep(3) +time.sleep(3) +find_followers = driver.find_elements(by=By.CSS_SELECTOR, value=".xt0psk2 a") +followers = [follower.text for follower in find_followers] +close_icon=driver.find_element(by=By.XPATH,value='/html/body/div[2]/div/div/div[2]/div/div/div[1]/div/div[2]/div/div/div/div/div[2]/div/div/div[1]/div/div[3]/div/button') +close_icon.click() +time.sleep(1) +select_following= driver.find_element(by=By.XPATH,value='/html/body/div[2]/div/div/div[1]/div/div/div/div[1]/div[1]/div[2]/section/main/div/header/section/ul/li[3]/a') +time.sleep(2) +select_following.click() +time.sleep(3) +modal_following=driver.find_element(by=By.XPATH,value='/html/body/div[2]/div/div/div[2]/div/div/div[1]/div/div[2]/div/div/div/div/div[2]/div/div/div[3]') +time.sleep(4) +for i in range(5): + driver.execute_script( + "arguments[0].scrollTop = arguments[0].scrollHeight", modal_following) + time.sleep(3) +time.sleep(3) +find_following = driver.find_elements(by=By.CSS_SELECTOR, value=".xt0psk2 a span div") +following = [following.text for following in find_following] +following= following[:len(following)-5] +print(following) +if followers and following: + with open("followers.txt", "a") as data_file: + for follower in followers: + data_file.write(f"{follower}\n") + with open("followings.txt","a") as data_file: + for f in following: + data_file.write(f"{f}\n") + +not_follow_you=list(set(following)-set(followers)) + +print(not_follow_you) diff --git a/Day54/advancedecorator.py b/Day54/advancedecorator.py new file mode 100644 index 0000000..b509a89 --- /dev/null +++ b/Day54/advancedecorator.py @@ -0,0 +1,17 @@ +class User: + def __init__(self,name): + self.name=name + self.is_logged_in=False +def is_authenticated_decorator(function): + def wrapper(*args,**kwargs): + if args[0].is_logged_in==True: + function(args[0]) + return wrapper + +@is_authenticated_decorator +def create_blog_post(user): + print(f"Hello {user.name}") +my_user=User("Ali") +my_user.is_logged_in=True + +create_blog_post(my_user) \ No newline at end of file diff --git a/Day54/main.py b/Day54/main.py new file mode 100644 index 0000000..0f84f2b --- /dev/null +++ b/Day54/main.py @@ -0,0 +1,12 @@ +from flask import Flask +from flask import render_template + +app= Flask(__name__) + +@app.route("/") +def homepage(name=None): + return render_template("index.html",name=name) + + +if __name__=="__main__": + app.run(debug=True) \ No newline at end of file diff --git a/Day54/server.py b/Day54/server.py new file mode 100644 index 0000000..34465e5 --- /dev/null +++ b/Day54/server.py @@ -0,0 +1,25 @@ +from flask import Flask + +app= Flask(__name__) + +game_list=[{ + "id":1, + "name":"LOL" + },{ + "id":2, + "name":"WarCraft" + }] +@app.route("/") +def home(): + return "Home Page" +@app.route("/games") +def games(): + return game_list +@app.route("/games/") +def show_game(game): + for g in game_list: + if g["name"]==game: + return f"Name:{game}" + return f"Name:{game} not found" +if __name__=="__main__": + app.run(debug=True) diff --git a/Day54/static/leiden.png b/Day54/static/leiden.png new file mode 100644 index 0000000..6f7b288 Binary files /dev/null and b/Day54/static/leiden.png differ diff --git a/Day54/templates/index.html b/Day54/templates/index.html new file mode 100644 index 0000000..ec20d8c --- /dev/null +++ b/Day54/templates/index.html @@ -0,0 +1,14 @@ + + + + + + + Rendered Template + + +

INDEX PAGE

+

Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptate dolores, est corrupti velit et corporis. Delectus voluptate doloremque alias veritatis, placeat labore atque eius exercitationem porro expedita? A, sint asperiores.

+ leiden + + \ No newline at end of file diff --git a/data.txt b/data.txt deleted file mode 100644 index 8517195..0000000 --- a/data.txt +++ /dev/null @@ -1 +0,0 @@ -test.com | test | #HqLW6*uc1K!2cC(l