python
# import sys
# print(sys.version)
# java
# for (int i=0; i < 5; i++){
# system.out.println(i);
# }
# python
# for i in range(0,5):
# print(i)
# list = [3,4,5,6,7,8]
# for i in list:
# print(i)
# str(age)
# name = "MD ALAMIN"
# age = str(30)
# age = 30
# print(name + " " + str(age))
# name = "MD ALAMIN"
# age = 30
# ratio = 2.3
# print(type(name))
# print(type(age))
# print(type(ratio))
# print("What is Your Name: ")
# name = input("What is Your Name: ")
# print("My name is : " + name)
# print("Hi " + name + " Congratulations")
# print(f"Hi {name} Congratulations")
# name = input("What is Your Name : ")
# age = input("How old are you? : ")
# age = int(age)
# day = age * 365
# min = age * 525948
# sec = age * 31556926
# print(f"{name} You has Lived for {day} day, {min} minutes, {sec} seconds")
# num1 = 3
# num2 = 5
# print(max(num1, num2))
# print(min(num1, num2))
# num1 = 10
# num2 = 6
# ans = num2 - num1
# print(ans)
# print(abs(ans))
# num1 = 10
# num2 = 6
# ans = num1 / num2
# print(ans)
# print(round(ans))
# import math
# num1 = 16.5
# sqrt = math.sqrt(num1)
# ceil = math.ceil(num1)
# floor = math.floor(num1)
# print(sqrt)
# print(ceil)
# print(floor)
# coursc_name = "We are learning python"
# new_len = len(coursc_name)
# print(new_len)
# print(coursc_name.upper())
# print(coursc_name.title())
# print(coursc_name.lower())
# print(coursc_name[1])
# print(coursc_name.find('e'))
# print(coursc_name.replace('r', 'R'))
# print(coursc_name.endswith('python'))
# print(coursc_name.endswith('learning'))
# print(coursc_name.endswith('n'))
# print(coursc_name.endswith('l'))
# print(coursc_name[0:10])
# print(coursc_name[5:10])
# print(coursc_name[5:-10])
# print(coursc_name[-5])
# fast_name = input('Write your First Name : ')
# Second_name = input('Write your Second Name : ')
# full_name = f"{fast_name} {Second_name}"
# print('Your Full Name Is : ', full_name)
# print('Title format : ', full_name.title())
# print('Upper Case format: ', full_name.upper())
# Chang_Second_name = input('Replace your Second Name : ')
# print(full_name, "Your New Name : " , fast_name + " " +Chang_Second_name)
# print(full_name, "Your New Name : " , full_name.replace(Second_name, Chang_Second_name))
# animal = "dog cat tiger"
# print("dog" in animal) # True
# print("dogS" in animal) # False
# has_PC = True
# has_Mobile = False
# has_resources = True
# if(has_PC and has_Mobile):
# print('True')
# else:
# print('False')
# if has_Mobile or has_resources:
# print('True2')
# else:
# print('False2')
# if (has_Mobile or has_resources) and has_PC:
# print('True2')
# else:
# print('False2')
# a = 10
# b = 20
# c = 30
# if(a > b):
# print("hi")
# if(a < b):
# print("hi")
# if a < b:
# print('ha11')
# if a < b and a < c:
# print('ha1133')
# else:
# print('ha1133else')
# number = input("write your phone number: ")
# if(len(number) == 11):
# print('11')
# else:
# print('else')
# a = 1
# while a <= 10:
# print(a)
# a = a + 1
# from ast import If
# secret_number = 5
# guess_count = 1
# guess_limit = 5
# # while True:
# while guess_count <= guess_limit:
# user_guess_number = int(input("Guess: "))
# guess_count += 1
# if(user_guess_number == secret_number):
# print('win')
# break
# else:
# print('Loss')
# check = ""
# light_on = False
# while check != 'sleep':
# check = input('> : ').lower()
# if check == 'on':
# if light_on == False:
# light_on = True
# print('On Mode')
# else:
# print('already On Mode')
# elif check == 'off':
# if light_on == True:
# light_on = False
# print('off Mode')
# else:
# print('already off Mode')
# elif check == 'sleep':
# print('sleep Mode')
# elif check == 'help':
# print('''1. on - light on
# 2. off - light off
# 3. sleep - exit
# ''')
# else:
# print("I don't understand your command")
# number = int(input("write a number: "))
# if number % 2 == 0:
# print(f' {number} Even Number')
# else:
# print(f' {number} Odd Number')
# while True:
# number = int(input("write a number: "))
# if number % 2 == 0:
# print(f' {number} Even Number')
# else:
# print(f' {number} Odd Number')
# for i in "programming":
# print(i)
# for i in range(0, 10):
# print(i)
# for i in range(0, 10 , 2):
# print(i)
# for i in ['dog', 'cat', 'tigair']:
# print(i)
# for name in ['dog', 'cat', 'tigair']:
# print("i lave" , name.title())
# for name in ['dog', 'cat', 'tigair']:
# print("i lave " + name.title())
# for i in range(1,6):
# print("*" * i)
# for i in range(5, 0, -1):
# print("*" * i)
# for x in range(0 , 2):
# for y in range(1 , 3):
# print(f"{x} {y}")
# for i in [5,1,3,1,1]:
# print("#"*i)
# animal_list = ['tiger1','tiger2','tiger3','tiger4','tiger5',]
# print(animal_list[2])
# print(animal_list[0:22])
# animal_list.append('tiger6')
# print(animal_list)
# animal_list.insert(2,"new tiger3")
# print(animal_list)
# animal_list[1] = "tiger3chng"
# print(animal_list)
# animal_list.remove('tiger1') #name
# print(animal_list)
# del animal_list[2] #index number
# print(animal_list)
# animal_list.pop()
# print(animal_list)
# animal_list.pop(2) #index number
# print(animal_list)
# new_list = animal_list.copy()
# animal_list.clear()
# print(animal_list)
# print(new_list)
# number_list1 = [1,2,3,4,]
# number_list2 = [5,6,7]
# print(number_list1 + number_list2) # [1, 2, 3, 4, 5, 6, 7]
# number_list1 = [1,2,3,4,]
# number_list2 = [5,6,7]
# number_list1.extend(number_list2)
# print(number_list1) # [1, 2, 3, 4, 5, 6, 7]
# num_list = [1, 2, 3, 4, 5, 6, 7]
# num_list2 = ['s', 'f', 'e', 'r']
# print(len(num_list))
# print(len(num_list2)) #_ len
# num_list = [1, 2, 3, 4, 5, 6, 7]
# print(max(num_list)) #_ max
# num_list = [1, 2, 3, 4, 5, 6, 7]
# num_list.sort()
# print(num_list)
# num_list = [1, 2, 3, 4, 5, 6, 7]
# num_list.reverse()
# print(num_list)
# num_list = [1, 2, 3, 4, 5, 6, 7]
# num_list.sort(reverse=True)
# print(num_list)
# matrix = [
# [1,2,3],
# [6,5,8],
# [3,4,9]
# ]
# print(matrix[2][1]) # 4
# print(matrix[2]) #_ [3, 4, 9]
#
# number = [4,5,5,6,9,8,75,4,6,5,4,7,9,4,5,5]
# number = number.count(5)
# print(number)
# Tuple Tuple Tuple Tuple
# number = (5,5,6,9,8,75,4,6,5,4,) # Tuple
# x = list(number) # list
# x[2] = 90
# print(x) # [5, 5, 90, 9, 8, 75, 4, 6, 5, 4]
# y = tuple(x)
# print(y) # (5, 5, 90, 9, 8, 75, 4, 6, 5, 4)
# Set Set Set Set Set Set
# number = [4,5,5,6,9,8,75,4,6,5,4,7,9,4,5,5]
# unique_numbers = []
# for unm in number:
# if unm not in unique_numbers:
# unique_numbers.append(unm)
# else:
# continue
# print(unique_numbers)
# print(set(number))
# numberset = {4,5,5,6,9,8,75}
# numberset.add(2)
# numberset.update([2,3,4,5,6,5,5,5,5,5,5,5,10,10,11,12,12])
# print(numberset)
# Dictionary Part_14
# dictionary = {
# "name" : "MD alamin",
# "age" : "31",
# "Phone Number" : "01791701496",
# }
# print(dictionary.get('name', "Invalid Value"))
# Practice Part_15
# number = {
# "1" : "One",
# "2" : "Two",
# "3" : "Three",
# "4" : "Four",
# "5" : "Five",
# "6" : "Six",
# "7" : "Seven",
# "8" : "Eight",
# "9" : "Nine",
# "0" : "Zero",
# }
# user_num = input("> ")
# for i in user_num:
# print(number.get(i, "(!)"), end=" ")
# List Comprehension Part_16
# name = []
# for i in "abcdefghi":
# name.append(i)
# print(name)
# name = [i for i in "dfgldfkgfdl"]
# print(name)
# Function Part_17
# def myFun():
# print('hi')
# myFun()
# def myFun2(name):
# print('Hi ' + name)
# myFun2('MD ALAMIN')
# myFun2('MD RAJ')
# def myFun3(name):
# print(f'Hi {name}')
# myFun3('MD ALAMIN')
# myFun3('MD RAJ')
# def myFun3(name, age):
# print(f'Hi {name} | my age {age}')
# myFun3('MD ALAMIN', 30)
# myFun3('MD RAJ', 25)
# def myFunction(*name):
# print(f'Hi {name[0]}')
# myFunction('MD RAJ', 'dfsdfs','sdfsdf')
# def myFunction(name="raj"):
# print(f'Hi {name}')
# myFunction('MD RAJ')
# myFunction()
# def myFunction(num1, num2):
# print(f' {num1 + num2}')
# print(f' {num1 * num2}')
# myFunction(5, 2)
# def myFunction(first_name, secone_name):
# print(f'first name: {first_name} | secone name: {secone_name}')
# myFunction(secone_name='ALAMIN', first_name='MD')
# Lambda Function Part 18
# num = lambda number1, number2 : number1 + 2
# print(num(3,2))
# num = lambda F_Name, L_name : str(F_Name).strip().title() + " " + str(L_name).strip().title()
# print(num("MD", " ALAMIN"))
# map Part 19
# number = map(int,input("number: ").split())
# number = list(number)
# print(number) # [1,2,3,4,5,6]
# print(*number) # 1 2 3 4 5 6
# Exception Handling Part 20
# age = int(input("age: "))
# print(age)
# try:
# age = int(input("age: "))
# print(age)
# except ValueError:
# print('Invalid Value')
# try:
# age = 21
# day = age/0
# print(day)
# except ZeroDivisionError:
# print("You can't divide age by 0")
# except ValueError:
# print('Invalid Value')
# try:
# age = int(input("age: "))
# print(age)
# except Exception:
# print('Invalid Value')
# try:
# age = 21
# day = age/0
# print(day)
# except Exception:
# print('Invalid Value')
# try:
# age = int(input("age: "))
# print(age)
# except Exception:
# print('Invalid Value')
# finally:
# print('finally Code')
# File Handling Part 21
# file = open('fille/text.txt', 'r') // read
# file = open('fille/text.txt', 'a') // Apand // ad new line
# file = open('fille/text.txt', 'w') // full write
# file = open('fille/text.txt', 'r')
# file = file.read()
# print(file.read())
# print(file.readline())
# print(file.readlines())
# for i in file:
# print(i, end="")
# file.close()
# for i in file:
# print(i.strip().split())
# file.close()
# file write
# file = open('fille/text.txt', 'a')
# file.write("\n"+"md alamin")
# file = open('fille/text.txt', 'w')
# file.write("md alamin")
# file = open('fille/text.txt', 'r')
# print(file.read())
# with open('fille/text.txt', mode='r') as read_file:
# # print(read_file.read())
# all_word = []
# for word in read_file:
# print(word)
# print(word.strip())
# print(word.split())
# print(word.strip().split())
# new_word = word.strip().split()
# all_word += new_word
# unique_lise = set(all_word)
# print(all_word)
# print(unique_lise)
# print(len(all_word))
# print(len(unique_lise))
# with open('fille/new_text.txt', mode='w') as write_file:
# for item in unique_lise:
# write_file.write(item)
# write_file.write("\n")
# for item in sorted(unique_lise):
# write_file.write(item)
# write_file.write("\n")
# delete file
# import os
# os.remove('fille/new_text.txt')
# class in Python Part 22
# class MyClass:
# def myFunction(self):
# print("My Function 1")
# def yourFunction(self):
# print("My Function 2")
# myFastClass = MyClass()
# myFastClass.p = 10
# myFastClass.q = 20
# myFastClass.myFunction()
# myFastClass.yourFunction()
# print(myFastClass.q)
# mysecondClass = MyClass()
# mysecondClass.m = 30
# print(mysecondClass.m)
# class MyClass:
# def __init__(self, x,y) -> None:
# self.x = x
# self.y = y
# pass
# def myFunction(self):
# print(f"My Function 1 {self.x}")
# def yourFunction(self):
# print(f"My Function 2 {self.y}")
# # myFastClass = MyClass(y=10,x=20)
# myFastClass = MyClass(10,20)
# print(myFastClass.x)
# print(myFastClass.myFunction())
# print(myFastClass.yourFunction())
# Inheritance in Python Part 23
# class Animal:
# def walk(self):
# print("Animal I can walk")
# class Cat:
# def Catwalk(self):
# print("Cat I can walk")
# class Dog(Animal):
# pass
# class Dog2(Animal,Cat):
# pass
# # Dog().walk()
# dog1 = Dog2()
# dog1.Catwalk()
# dog1.walk()
# Modules in Python Part 24
# import myconverter
# mymaxNumber = myconverter.find_max([1,200,5,48,7,98])
# print(mymaxNumber)
# from myconverter import find_max
# mymaxNumber = find_max([1,200,5,48,7,98])
# print(mymaxNumber)
# Packages in Python Part 25
GmailLogin
import undetected_chromedriver as uc
from selenium.webdriver.common.by import By
import time
class GmailLogin:
def __init__(self,email,pwd):
self.email = email
self.pwd = pwd
self.url = "https://accounts.google.com/signin"
self.driver = uc.Chrome(driver_executable_path="chromedriver.exe")
self.open_browser(self.url)
def open_browser(self,url):
self.driver.get(url)
time.sleep(1)
def login_gmail(self):
self.driver.find_element(By.ID,"identifierId").send_keys(self.email)
time.sleep(1)
self.driver.find_element(By.XPATH,"/html[1]/body[1]/div[1]/div[1]/div[2]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/button[1]").click()
time.sleep(1)
# self.driver.find_element(By.XPATH,"/html[1]/body[1]/div[1]/div[1]/div[2]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/form[1]/span[1]/section[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/input[1]").send_keys(self.pwd)
# time.sleep(10)
# self.driver.find_element(By.XPATH,"/html[1]/body[1]/div[1]/div[1]/div[2]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/button[1]").click()
# time.sleep(1)
if __name__ == '__main__':
gmail1 = GmailLogin("ya26202","12312rsdfsdfa")
gmail1.login_gmail()
gmail2 = GmailLogin("ya26202","12312rsdfsdfa")
gmail2.login_gmail()
run_interval
import undetected_chromedriver as uc
from selenium.webdriver.common.by import By
import time
class Automation:
def __init__(self,interval_count,url,user_data_dir,proxy=None):
self.interval_count = interval_count
self.url = url
self.proxy = proxy
self.user_data_dir = user_data_dir
def run_interval(self,profile_number):
options = uc.ChromeOptions()
options.user_data_dir = self.user_data_dir
options.add_argument(f"--profile-directory=Facebook {profile_number}")
browser =uc.Chrome(driver_executable_path="chromedriver.exe",options=options)
browser.get(self.url)
time.sleep(2)
browser.quit()
def start(self):
for i in range(self.interval_count):
self.run_interval(i+1)
proxy-server
import undetected_chromedriver.v2 as uc
import time
# PROXY = "166.78.156.44:47372"
# PROXY = "212.103.125.48:1080"
PROXY = "62.113.115.94:16072"
# chrome://version
options = uc.ChromeOptions()
options.user_data_dir = "C:\\User Data"
# options.add_argument("--profile-directory=Profile 5")
if __name__ == '__main__':
options.add_argument('--proxy-server=%s' %PROXY)
driver = uc.Chrome(driver_executable_path="chromedriver.exe",options=options)
driver.get("https://google.com")
time.sleep(100)
# import undetected_chromedriver as uc
# import time
from selenium import webdriver
PROXY = "62.113.115.94:16072"
# if __name__ == '__main__':
options = webdriver.ChromeOptions()
options.add_argument('--proxy-server=%s' % PROXY)
driver = webdriver.Chrome(executable_path="chromedriver.exe",options=options)
driver.get("https://google.com")
# time.sleep(100)
from selenium import webdriver
driver = webdriver.Chrome("./chromedriver.exe")
# driver = webdriver.Firefox()
driver.get("https://youtube.com")
from selenium import webdriver
driver = webdriver.Chrome("./chromedriver.exe")
driver.get("https://www.google.com/")
# element = driver.find_element("name","q")
search_input_field = driver.find_element("xpath","/html/body/div[1]/div[3]/form/div[1]/div[1]/div[1]/div/div[2]/input")
# print(element)
search_input_field.send_keys("@yasinized")
search_input_field.submit()
res = driver.find_element("xpath","//*[@id='rso']/div/div/div/div[1]/div/a")
res.click()
from selenium import webdriver
driver = webdriver.Chrome("./chromedriver.exe")
driver.get("https://www.google.com/")
search_input_field = driver.find_element("xpath","/html/body/div[1]/div[3]/form/div[1]/div[1]/div[1]/div/div[2]/input")
search_input_field.send_keys("google accounts sign in")
search_input_field.submit()
google_signin_link = driver.find_element("xpath","//*[@id='rso']/div[1]/div/div[1]/div/a")
google_signin_link.click()
gmail_input_element = driver.find_element("xpath","/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/div/form/span/section/div/div/div[1]/div/div[1]/div/div[1]/input")
gmail_input_element.send_keys("")
click_next_btn = driver.find_element("xpath","/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div/div/button")
click_next_btn.click()
# /html/body/ytd-app/div[1]/div/ytd-masthead/div[3]/div[2]/ytd-searchbox/form/div[1]/div[1]/input
# https://www.youtube.com/watch?v=MUMCZZl9QCY
from selenium import webdriver
driver = webdriver.Chrome("./chromedriver.exe")
driver.get("https://iconmovie24.com/login")
# search_input_field = driver.find_element("xpath","/html/body/ytd-app/div[1]/div/ytd-masthead/div[3]/div[2]/ytd-searchbox/form/div[1]/div[1]/input")
# search_input_field.send_keys("https://www.youtube.com/watch?v=MUMCZZl9QCY")
# search_input_field.submit()
# https://iconmovie24.com/login
# google_signin_link = driver.find_element("xpath","//*[@id='rso']/div[1]/div/div[1]/div/a")
# google_signin_link.click()
# gmail_input_element = driver.find_element("xpath","/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/div/form/span/section/div/div/div[1]/div/div[1]/div/div[1]/input")
# gmail_input_element.send_keys("")
# click_next_btn = driver.find_element("xpath","/html/body/ytd-app/div[1]/ytd-page-manager/ytd-search/div[1]/ytd-two-column-search-results-renderer/div/ytd-section-list-renderer/div[2]/ytd-item-section-renderer/div[3]/ytd-video-renderer[1]/div[1]/div/div[1]/div/h3/a")
# click_next_btn.click()
run_interval
import undetected_chromedriver as uc
from selenium.webdriver.common.by import By
import time
INTERVAL_TIME = 5
def google(profile_name):
options = uc.ChromeOptions()
options.user_data_dir = "C:\\User Data"
options.add_argument(f"--profile-directory={profile_name}")
browser =uc.Chrome(driver_executable_path="chromedriver.exe",options=options)
browser.get("https://google.com")
time.sleep(10)
browser.quit()
# if __name__ == '__main__':
# for i in range(INTERVAL_TIME):
# google(f"Facebook {i+1}")
class Automation:
def __init__(self,interval_count,url,user_data_dir,proxy=None):
self.interval_count = interval_count
self.url = url
self.proxy = proxy
self.user_data_dir = user_data_dir
def run_interval(self,profile_number):
options = uc.ChromeOptions()
options.user_data_dir = self.user_data_dir
options.add_argument(f"--profile-directory=Facebook {profile_number}")
browser =uc.Chrome(driver_executable_path="chromedriver.exe",options=options)
browser.get(self.url)
time.sleep(2)
browser.quit()
def start(self):
for i in range(self.interval_count):
self.run_interval(i+1)
if __name__ == '__main__':
automation = Automation(user_data_dir="C:\\User Data",url="https://google.com",interval_count=5)
automation.start()
webbrowser
import webbrowser
chrome_path1 = 'C:/Program Files/Google/Chrome/Application/chrome.exe %s'
chrome_path2 = 'C:/Program Files/Mozilla Firefox/firefox.exe %s'
webbrowser.get(chrome_path2).open("https://www.google.com")
# import webbrowser
# chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
# webbrowser.get(chrome_path).open('http://docs.python.org/')
إرسال تعليق