├── demoProject ├── db.sqlite3 ├── demoProject │ ├── __init__.py │ ├── __pycache__ │ │ ├── urls.cpython-36.pyc │ │ ├── wsgi.cpython-36.pyc │ │ ├── __init__.cpython-36.pyc │ │ └── settings.cpython-36.pyc │ ├── wsgi.py │ ├── urls.py │ └── settings.py ├── MachineLearnDemo │ ├── __init__.py │ ├── migrations │ │ ├── __init__.py │ │ └── __pycache__ │ │ │ └── __init__.cpython-36.pyc │ ├── models.py │ ├── admin.py │ ├── tests.py │ ├── apps.py │ ├── __pycache__ │ │ ├── admin.cpython-36.pyc │ │ ├── models.cpython-36.pyc │ │ ├── views.cpython-36.pyc │ │ └── __init__.cpython-36.pyc │ └── views.py ├── manage.py ├── Untitled.ipynb ├── .ipynb_checkpoints │ └── Untitled-checkpoint.ipynb └── template │ └── startpage.html ├── dummyProject ├── db.sqlite3 ├── firstapp │ ├── __init__.py │ ├── migrations │ │ └── __init__.py │ ├── models.py │ ├── tests.py │ ├── admin.py │ ├── apps.py │ ├── __pycache__ │ │ ├── views.cpython-36.pyc │ │ └── __init__.cpython-36.pyc │ └── views.py ├── dummyProject │ ├── __init__.py │ ├── __pycache__ │ │ ├── urls.cpython-36.pyc │ │ ├── wsgi.cpython-36.pyc │ │ ├── __init__.cpython-36.pyc │ │ └── settings.cpython-36.pyc │ ├── asgi.py │ ├── wsgi.py │ ├── urls.py │ └── settings.py └── manage.py ├── Python Programming Notebooks ├── saveFile.txt ├── sampleTextFile.txt ├── someImage.png └── Zip function in Python.ipynb ├── selenium ├── somefile.png ├── geckodriver.exe ├── chromedriver.exe ├── Selenium 2.ipynb ├── Selenium.ipynb └── .ipynb_checkpoints │ └── Selenium-checkpoint.ipynb ├── Sample - Superstore.xls ├── instagramAutomation ├── sample.png ├── so4.xml ├── INsta like and follow.ipynb ├── insta Uplaod images-Self.ipynb ├── .ipynb_checkpoints │ ├── insta Uplaod images-Self-checkpoint.ipynb │ └── insta Uplaod images-checkpoint.ipynb ├── insta Uplaod images.ipynb ├── so3.xml └── someHier.xml ├── recursion ├── recursive │ ├── Mandelbrot.jpg │ ├── seashells2.jpg │ ├── image_05_001.jpg │ ├── 1_-7-NhP6zGFbb8tjceyGExg.png │ ├── 1_0CHEA3ywVJmuiizlWLBsZQ.png │ └── 1_sx-fjgFhKYEJy6JLvNtIDQ.png ├── recursion.ipynb └── .ipynb_checkpoints │ └── recursion-checkpoint.ipynb ├── statistics tables ├── Z-Table sample.png ├── f-table-0.025.jpg └── t table sample.png ├── README.md ├── .ipynb_checkpoints ├── Zip function in Python-checkpoint.ipynb ├── Selenium 2-checkpoint.ipynb ├── Exceptional Handling-checkpoint.ipynb └── ANOVA-checkpoint.ipynb └── mongodb └── mongodb connection.ipynb /demoProject/db.sqlite3: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dummyProject/db.sqlite3: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dummyProject/firstapp/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demoProject/demoProject/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dummyProject/dummyProject/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demoProject/MachineLearnDemo/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dummyProject/firstapp/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demoProject/MachineLearnDemo/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Python Programming Notebooks/saveFile.txt: -------------------------------------------------------------------------------- 1 | this is a TEXT file. The world is great. -------------------------------------------------------------------------------- /Python Programming Notebooks/sampleTextFile.txt: -------------------------------------------------------------------------------- 1 | this is a TEXT file. The world is great. -------------------------------------------------------------------------------- /dummyProject/firstapp/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /dummyProject/firstapp/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /demoProject/MachineLearnDemo/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /dummyProject/firstapp/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /demoProject/MachineLearnDemo/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /demoProject/MachineLearnDemo/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /selenium/somefile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/selenium/somefile.png -------------------------------------------------------------------------------- /Sample - Superstore.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/Sample - Superstore.xls -------------------------------------------------------------------------------- /selenium/geckodriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/selenium/geckodriver.exe -------------------------------------------------------------------------------- /selenium/chromedriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/selenium/chromedriver.exe -------------------------------------------------------------------------------- /instagramAutomation/sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/instagramAutomation/sample.png -------------------------------------------------------------------------------- /recursion/recursive/Mandelbrot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/recursion/recursive/Mandelbrot.jpg -------------------------------------------------------------------------------- /recursion/recursive/seashells2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/recursion/recursive/seashells2.jpg -------------------------------------------------------------------------------- /dummyProject/firstapp/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class FirstappConfig(AppConfig): 5 | name = 'firstapp' 6 | -------------------------------------------------------------------------------- /recursion/recursive/image_05_001.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/recursion/recursive/image_05_001.jpg -------------------------------------------------------------------------------- /statistics tables/Z-Table sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/statistics tables/Z-Table sample.png -------------------------------------------------------------------------------- /statistics tables/f-table-0.025.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/statistics tables/f-table-0.025.jpg -------------------------------------------------------------------------------- /statistics tables/t table sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/statistics tables/t table sample.png -------------------------------------------------------------------------------- /Python Programming Notebooks/someImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/Python Programming Notebooks/someImage.png -------------------------------------------------------------------------------- /demoProject/MachineLearnDemo/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class MachinelearndemoConfig(AppConfig): 5 | name = 'MachineLearnDemo' 6 | -------------------------------------------------------------------------------- /recursion/recursive/1_-7-NhP6zGFbb8tjceyGExg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/recursion/recursive/1_-7-NhP6zGFbb8tjceyGExg.png -------------------------------------------------------------------------------- /recursion/recursive/1_0CHEA3ywVJmuiizlWLBsZQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/recursion/recursive/1_0CHEA3ywVJmuiizlWLBsZQ.png -------------------------------------------------------------------------------- /recursion/recursive/1_sx-fjgFhKYEJy6JLvNtIDQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/recursion/recursive/1_sx-fjgFhKYEJy6JLvNtIDQ.png -------------------------------------------------------------------------------- /dummyProject/firstapp/__pycache__/views.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/dummyProject/firstapp/__pycache__/views.cpython-36.pyc -------------------------------------------------------------------------------- /demoProject/demoProject/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/demoProject/demoProject/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /demoProject/demoProject/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/demoProject/demoProject/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /dummyProject/dummyProject/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/dummyProject/dummyProject/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /dummyProject/dummyProject/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/dummyProject/dummyProject/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /dummyProject/firstapp/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/dummyProject/firstapp/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /demoProject/demoProject/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/demoProject/demoProject/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /demoProject/demoProject/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/demoProject/demoProject/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /demoProject/MachineLearnDemo/__pycache__/admin.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/demoProject/MachineLearnDemo/__pycache__/admin.cpython-36.pyc -------------------------------------------------------------------------------- /demoProject/MachineLearnDemo/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/demoProject/MachineLearnDemo/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /demoProject/MachineLearnDemo/__pycache__/views.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/demoProject/MachineLearnDemo/__pycache__/views.cpython-36.pyc -------------------------------------------------------------------------------- /dummyProject/dummyProject/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/dummyProject/dummyProject/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /dummyProject/dummyProject/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/dummyProject/dummyProject/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /demoProject/MachineLearnDemo/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/demoProject/MachineLearnDemo/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /demoProject/MachineLearnDemo/migrations/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharmasw/Data-Science-with-python/HEAD/demoProject/MachineLearnDemo/migrations/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /dummyProject/firstapp/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.http import HttpResponse,JsonResponse 3 | 4 | # Create your views here. 5 | 6 | 7 | # def index(requests): 8 | # return HttpResponse('Hello World! 2') 9 | 10 | 11 | 12 | def index(requests): 13 | return JsonResponse({'a':1}) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Data-Science-with-python 2 | This repo has all the required materials of the Data science with python video series. 3 | 4 | 5 | The youtube channel: https://www.youtube.com/channel/UCKXQTY--Ha6_aT8zKxQ0rGw 6 | 7 | Please subscribe to my channel by clicking on the link: https://www.youtube.com/channel/UCKXQTY--Ha6_aT8zKxQ0rGw?sub_confirmation=1 8 | -------------------------------------------------------------------------------- /demoProject/MachineLearnDemo/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.http import HttpResponse,JsonResponse 3 | 4 | # Create your views here. 5 | # def index(request): 6 | # return HttpResponse('a') 7 | 8 | def index(request): 9 | context={'a':1} 10 | return render(request, 'startpage.html', context) 11 | 12 | # def index(request): 13 | # return JsonResponse({'a':1}) -------------------------------------------------------------------------------- /demoProject/demoProject/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for demoProject project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demoProject.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /dummyProject/dummyProject/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for dummyProject project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dummyProject.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /dummyProject/dummyProject/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for dummyProject project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dummyProject.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /demoProject/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demoProject.settings') 9 | try: 10 | from django.core.management import execute_from_command_line 11 | except ImportError as exc: 12 | raise ImportError( 13 | "Couldn't import Django. Are you sure it's installed and " 14 | "available on your PYTHONPATH environment variable? Did you " 15 | "forget to activate a virtual environment?" 16 | ) from exc 17 | execute_from_command_line(sys.argv) 18 | 19 | 20 | if __name__ == '__main__': 21 | main() 22 | -------------------------------------------------------------------------------- /dummyProject/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dummyProject.settings') 9 | try: 10 | from django.core.management import execute_from_command_line 11 | except ImportError as exc: 12 | raise ImportError( 13 | "Couldn't import Django. Are you sure it's installed and " 14 | "available on your PYTHONPATH environment variable? Did you " 15 | "forget to activate a virtual environment?" 16 | ) from exc 17 | execute_from_command_line(sys.argv) 18 | 19 | 20 | if __name__ == '__main__': 21 | main() 22 | -------------------------------------------------------------------------------- /dummyProject/dummyProject/urls.py: -------------------------------------------------------------------------------- 1 | """dummyProject URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/3.0/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path 18 | from django.conf.urls import url 19 | from firstapp import views 20 | 21 | urlpatterns = [ 22 | url('^$',views.index,name='homepage'), 23 | path('admin/', admin.site.urls), 24 | ] 25 | -------------------------------------------------------------------------------- /demoProject/demoProject/urls.py: -------------------------------------------------------------------------------- 1 | """demoProject URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.2/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path 18 | from django.conf.urls import url 19 | from MachineLearnDemo import views 20 | 21 | urlpatterns = [ 22 | path('admin/', admin.site.urls), 23 | url('^$',views.index,name='homepage'), 24 | 25 | 26 | ] 27 | -------------------------------------------------------------------------------- /demoProject/Untitled.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import requests,json" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 3, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "kk=requests.get('http://localhost:8000')" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 4, 24 | "metadata": {}, 25 | "outputs": [ 26 | { 27 | "data": { 28 | "text/plain": [ 29 | "'{\"a\": 1}'" 30 | ] 31 | }, 32 | "execution_count": 4, 33 | "metadata": {}, 34 | "output_type": "execute_result" 35 | } 36 | ], 37 | "source": [ 38 | "kk.text" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": null, 44 | "metadata": {}, 45 | "outputs": [], 46 | "source": [] 47 | } 48 | ], 49 | "metadata": { 50 | "kernelspec": { 51 | "display_name": "Python 3", 52 | "language": "python", 53 | "name": "python3" 54 | }, 55 | "language_info": { 56 | "codemirror_mode": { 57 | "name": "ipython", 58 | "version": 3 59 | }, 60 | "file_extension": ".py", 61 | "mimetype": "text/x-python", 62 | "name": "python", 63 | "nbconvert_exporter": "python", 64 | "pygments_lexer": "ipython3", 65 | "version": "3.6.8" 66 | } 67 | }, 68 | "nbformat": 4, 69 | "nbformat_minor": 2 70 | } 71 | -------------------------------------------------------------------------------- /demoProject/.ipynb_checkpoints/Untitled-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import requests,json" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 3, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "kk=requests.get('http://localhost:8000')" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 4, 24 | "metadata": {}, 25 | "outputs": [ 26 | { 27 | "data": { 28 | "text/plain": [ 29 | "'{\"a\": 1}'" 30 | ] 31 | }, 32 | "execution_count": 4, 33 | "metadata": {}, 34 | "output_type": "execute_result" 35 | } 36 | ], 37 | "source": [ 38 | "kk.text" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": null, 44 | "metadata": {}, 45 | "outputs": [], 46 | "source": [] 47 | } 48 | ], 49 | "metadata": { 50 | "kernelspec": { 51 | "display_name": "Python 3", 52 | "language": "python", 53 | "name": "python3" 54 | }, 55 | "language_info": { 56 | "codemirror_mode": { 57 | "name": "ipython", 58 | "version": 3 59 | }, 60 | "file_extension": ".py", 61 | "mimetype": "text/x-python", 62 | "name": "python", 63 | "nbconvert_exporter": "python", 64 | "pygments_lexer": "ipython3", 65 | "version": "3.6.8" 66 | } 67 | }, 68 | "nbformat": 4, 69 | "nbformat_minor": 2 70 | } 71 | -------------------------------------------------------------------------------- /demoProject/template/startpage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 |

Form with checkboxes

11 | 12 |
13 | 19 | 25 | 26 |
27 | 28 | 29 |

Form with Radio buttons

30 | 31 |
32 | 33 |
34 | 35 |
36 | 37 |

38 | 39 |
40 | 41 |

Form with Dropdown option

42 | 43 |

Select one of the options

44 | 45 |
46 | 47 | 53 | 54 |
55 | 56 | 57 |

Extract Data from table

58 |
59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 |
MonthSavings
January$100
February$110
March$120
April$130
May$140
June$130
July$150
August$120
September$160
October$130
November$230
109 | 110 | 111 | 112 |

Hello World!

113 | 114 | 115 | 116 |

Hello World!

117 | 118 | 119 |

Hello World!

120 | 121 | 122 |

Hello World!

123 | 124 | 125 |

Hello World!

126 | 127 | 128 |

Hello World!

129 | 130 | 131 |

Hello World!

132 | 133 | 134 |

Hello World!

135 | 136 | 137 |

Hello World!

138 | 139 | 140 | 141 |

Hello World!

142 |
143 | -------------------------------------------------------------------------------- /dummyProject/dummyProject/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for dummyProject project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.0.3. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/3.0/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = 'h(^90_s@f7-=ax)dx%nh$+q$x_jaf(v83w*br-y@4vh8j3equa' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | ] 41 | 42 | MIDDLEWARE = [ 43 | 'django.middleware.security.SecurityMiddleware', 44 | 'django.contrib.sessions.middleware.SessionMiddleware', 45 | 'django.middleware.common.CommonMiddleware', 46 | 'django.middleware.csrf.CsrfViewMiddleware', 47 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 48 | 'django.contrib.messages.middleware.MessageMiddleware', 49 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 50 | ] 51 | 52 | ROOT_URLCONF = 'dummyProject.urls' 53 | 54 | TEMPLATES = [ 55 | { 56 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 57 | 'DIRS': [], 58 | 'APP_DIRS': True, 59 | 'OPTIONS': { 60 | 'context_processors': [ 61 | 'django.template.context_processors.debug', 62 | 'django.template.context_processors.request', 63 | 'django.contrib.auth.context_processors.auth', 64 | 'django.contrib.messages.context_processors.messages', 65 | ], 66 | }, 67 | }, 68 | ] 69 | 70 | WSGI_APPLICATION = 'dummyProject.wsgi.application' 71 | 72 | 73 | # Database 74 | # https://docs.djangoproject.com/en/3.0/ref/settings/#databases 75 | 76 | DATABASES = { 77 | 'default': { 78 | 'ENGINE': 'django.db.backends.sqlite3', 79 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 80 | } 81 | } 82 | 83 | 84 | # Password validation 85 | # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators 86 | 87 | AUTH_PASSWORD_VALIDATORS = [ 88 | { 89 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 90 | }, 91 | { 92 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 93 | }, 94 | { 95 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 96 | }, 97 | { 98 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 99 | }, 100 | ] 101 | 102 | 103 | # Internationalization 104 | # https://docs.djangoproject.com/en/3.0/topics/i18n/ 105 | 106 | LANGUAGE_CODE = 'en-us' 107 | 108 | TIME_ZONE = 'UTC' 109 | 110 | USE_I18N = True 111 | 112 | USE_L10N = True 113 | 114 | USE_TZ = True 115 | 116 | 117 | # Static files (CSS, JavaScript, Images) 118 | # https://docs.djangoproject.com/en/3.0/howto/static-files/ 119 | 120 | STATIC_URL = '/static/' 121 | -------------------------------------------------------------------------------- /demoProject/demoProject/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for demoProject project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.2.3. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.2/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.2/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '$5lyis8m_j97-v$y87s(h@n%oa(-gfg^0%6cr$ylf9+u8k@k*b' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'MachineLearnDemo', 41 | ] 42 | 43 | MIDDLEWARE = [ 44 | 'django.middleware.security.SecurityMiddleware', 45 | 'django.contrib.sessions.middleware.SessionMiddleware', 46 | 'django.middleware.common.CommonMiddleware', 47 | 'django.middleware.csrf.CsrfViewMiddleware', 48 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 49 | 'django.contrib.messages.middleware.MessageMiddleware', 50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 51 | ] 52 | 53 | ROOT_URLCONF = 'demoProject.urls' 54 | print ('BASE_DIR',BASE_DIR,',>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') 55 | print (os.path.join(BASE_DIR,'template')) 56 | TEMPLATES = [ 57 | { 58 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 59 | 'DIRS': ['template', 60 | os.path.join(BASE_DIR,'template')], 61 | 'APP_DIRS': True, 62 | 'OPTIONS': { 63 | 'context_processors': [ 64 | 'django.template.context_processors.debug', 65 | 'django.template.context_processors.request', 66 | 'django.contrib.auth.context_processors.auth', 67 | 'django.contrib.messages.context_processors.messages', 68 | ], 69 | }, 70 | }, 71 | ] 72 | 73 | WSGI_APPLICATION = 'demoProject.wsgi.application' 74 | 75 | 76 | # Database 77 | # https://docs.djangoproject.com/en/2.2/ref/settings/#databases 78 | 79 | DATABASES = { 80 | 'default': { 81 | 'ENGINE': 'django.db.backends.sqlite3', 82 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 83 | } 84 | } 85 | 86 | 87 | # Password validation 88 | # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators 89 | 90 | AUTH_PASSWORD_VALIDATORS = [ 91 | { 92 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 93 | }, 94 | { 95 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 96 | }, 97 | { 98 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 99 | }, 100 | { 101 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 102 | }, 103 | ] 104 | 105 | 106 | # Internationalization 107 | # https://docs.djangoproject.com/en/2.2/topics/i18n/ 108 | 109 | LANGUAGE_CODE = 'en-us' 110 | 111 | TIME_ZONE = 'UTC' 112 | 113 | USE_I18N = True 114 | 115 | USE_L10N = True 116 | 117 | USE_TZ = True 118 | 119 | 120 | # Static files (CSS, JavaScript, Images) 121 | # https://docs.djangoproject.com/en/2.2/howto/static-files/ 122 | 123 | STATIC_URL = '/static/' 124 | -------------------------------------------------------------------------------- /instagramAutomation/so4.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /recursion/recursion.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## Recursion Functions in Python" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | " A function that calls itself directly (or indirectly) to solve a smaller version of its task until a final call which does not require a self-call is a recursive function." 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 1, 20 | "metadata": {}, 21 | "outputs": [], 22 | "source": [ 23 | "def reFunc(x):\n", 24 | " return reFunc(x)" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 2, 30 | "metadata": {}, 31 | "outputs": [ 32 | { 33 | "ename": "RecursionError", 34 | "evalue": "maximum recursion depth exceeded", 35 | "output_type": "error", 36 | "traceback": [ 37 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 38 | "\u001b[1;31mRecursionError\u001b[0m Traceback (most recent call last)", 39 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mreFunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 40 | "\u001b[1;32m\u001b[0m in \u001b[0;36mreFunc\u001b[1;34m(x)\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mreFunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mreFunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 41 | "... last 1 frames repeated, from the frame below ...\n", 42 | "\u001b[1;32m\u001b[0m in \u001b[0;36mreFunc\u001b[1;34m(x)\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mreFunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mreFunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 43 | "\u001b[1;31mRecursionError\u001b[0m: maximum recursion depth exceeded" 44 | ] 45 | } 46 | ], 47 | "source": [ 48 | "reFunc(2)" 49 | ] 50 | }, 51 | { 52 | "cell_type": "markdown", 53 | "metadata": {}, 54 | "source": [ 55 | "## Stack overflow issue" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": null, 61 | "metadata": {}, 62 | "outputs": [], 63 | "source": [ 64 | "if input value is > 10^4" 65 | ] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "execution_count": null, 70 | "metadata": {}, 71 | "outputs": [], 72 | "source": [] 73 | }, 74 | { 75 | "cell_type": "markdown", 76 | "metadata": {}, 77 | "source": [ 78 | "## Increasing recursion limit" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": null, 84 | "metadata": {}, 85 | "outputs": [], 86 | "source": [ 87 | "import sys\n", 88 | "sys.setrecursionlimit(1500)" 89 | ] 90 | }, 91 | { 92 | "cell_type": "markdown", 93 | "metadata": {}, 94 | "source": [ 95 | "## Example of a factorial" 96 | ] 97 | }, 98 | { 99 | "cell_type": "markdown", 100 | "metadata": {}, 101 | "source": [ 102 | "$$ n! = n* (n-1)! $$" 103 | ] 104 | }, 105 | { 106 | "cell_type": "markdown", 107 | "metadata": {}, 108 | "source": [ 109 | "$$5! = 5* (4* (3 * (2*(1 ))))$$" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": 3, 115 | "metadata": {}, 116 | "outputs": [], 117 | "source": [ 118 | "def factorialCal(x):\n", 119 | "# print(x)\n", 120 | " if x ==0:\n", 121 | " return 1\n", 122 | " else:\n", 123 | " kk=x*(factorialCal(x-1))\n", 124 | "# print (x,kk)\n", 125 | " return kk" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": 4, 131 | "metadata": {}, 132 | "outputs": [ 133 | { 134 | "data": { 135 | "text/plain": [ 136 | "608281864034267560872252163321295376887552831379210240000000000" 137 | ] 138 | }, 139 | "execution_count": 4, 140 | "metadata": {}, 141 | "output_type": "execute_result" 142 | } 143 | ], 144 | "source": [ 145 | "factorialCal(49)" 146 | ] 147 | }, 148 | { 149 | "cell_type": "markdown", 150 | "metadata": {}, 151 | "source": [ 152 | "## Tail recursive Functions" 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": null, 158 | "metadata": {}, 159 | "outputs": [], 160 | "source": [] 161 | }, 162 | { 163 | "cell_type": "code", 164 | "execution_count": 6, 165 | "metadata": {}, 166 | "outputs": [], 167 | "source": [ 168 | "def fatcorialTail(x,xVal):\n", 169 | " if x==0:\n", 170 | " return xVal\n", 171 | " return fatcorialTail(x-1,x*xVal)" 172 | ] 173 | }, 174 | { 175 | "cell_type": "code", 176 | "execution_count": 7, 177 | "metadata": {}, 178 | "outputs": [], 179 | "source": [ 180 | "def factVal(x): \n", 181 | " return fatcorialTail(x, 1) " 182 | ] 183 | }, 184 | { 185 | "cell_type": "code", 186 | "execution_count": 8, 187 | "metadata": {}, 188 | "outputs": [ 189 | { 190 | "data": { 191 | "text/plain": [ 192 | "120" 193 | ] 194 | }, 195 | "execution_count": 8, 196 | "metadata": {}, 197 | "output_type": "execute_result" 198 | } 199 | ], 200 | "source": [ 201 | "factVal(5)" 202 | ] 203 | }, 204 | { 205 | "cell_type": "code", 206 | "execution_count": null, 207 | "metadata": {}, 208 | "outputs": [], 209 | "source": [] 210 | } 211 | ], 212 | "metadata": { 213 | "kernelspec": { 214 | "display_name": "Python 3", 215 | "language": "python", 216 | "name": "python3" 217 | }, 218 | "language_info": { 219 | "codemirror_mode": { 220 | "name": "ipython", 221 | "version": 3 222 | }, 223 | "file_extension": ".py", 224 | "mimetype": "text/x-python", 225 | "name": "python", 226 | "nbconvert_exporter": "python", 227 | "pygments_lexer": "ipython3", 228 | "version": "3.6.9" 229 | } 230 | }, 231 | "nbformat": 4, 232 | "nbformat_minor": 2 233 | } 234 | -------------------------------------------------------------------------------- /instagramAutomation/INsta like and follow.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "data": { 10 | "text/plain": [ 11 | "{'currentPackageName': 'com.sec.android.app.launcher',\n", 12 | " 'displayHeight': 2058,\n", 13 | " 'displayRotation': 0,\n", 14 | " 'displaySizeDpX': 320,\n", 15 | " 'displaySizeDpY': 658,\n", 16 | " 'displayWidth': 1080,\n", 17 | " 'productName': 'starqlteue',\n", 18 | " 'screenOn': True,\n", 19 | " 'sdkInt': 29,\n", 20 | " 'naturalOrientation': True}" 21 | ] 22 | }, 23 | "execution_count": 1, 24 | "metadata": {}, 25 | "output_type": "execute_result" 26 | } 27 | ], 28 | "source": [ 29 | "from uiautomator import device as d\n", 30 | "from uiautomator import Device\n", 31 | "from time import sleep\n", 32 | "import os\n", 33 | "\n", 34 | "d.infod = Device('375637504c583398')\n", 35 | "\n", 36 | "d.info" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 2, 42 | "metadata": {}, 43 | "outputs": [ 44 | { 45 | "data": { 46 | "text/plain": [ 47 | "True" 48 | ] 49 | }, 50 | "execution_count": 2, 51 | "metadata": {}, 52 | "output_type": "execute_result" 53 | } 54 | ], 55 | "source": [ 56 | "d.press.home()\n", 57 | "sx, sy, ex, ey= 100 ,150,100,450\n", 58 | "d.swipe(sx, sy, ex, ey, steps=5)" 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": 3, 64 | "metadata": {}, 65 | "outputs": [ 66 | { 67 | "data": { 68 | "text/plain": [ 69 | "True" 70 | ] 71 | }, 72 | "execution_count": 3, 73 | "metadata": {}, 74 | "output_type": "execute_result" 75 | } 76 | ], 77 | "source": [ 78 | "instaVal=d(text='Instagram', className='android.widget.TextView')\n", 79 | "instaVal.click()" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": 6, 85 | "metadata": {}, 86 | "outputs": [ 87 | { 88 | "data": { 89 | "text/plain": [ 90 | "True" 91 | ] 92 | }, 93 | "execution_count": 6, 94 | "metadata": {}, 95 | "output_type": "execute_result" 96 | } 97 | ], 98 | "source": [ 99 | "sx, sy, ex, ey= 560,800,560 ,150\n", 100 | "d.swipe(sx, sy, ex, ey, steps=10)" 101 | ] 102 | }, 103 | { 104 | "cell_type": "code", 105 | "execution_count": null, 106 | "metadata": {}, 107 | "outputs": [], 108 | "source": [ 109 | "pp=d(className='android.widget.TextView',text='Downloads')#,index=\"2\")\n", 110 | "pp.click()" 111 | ] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "execution_count": null, 116 | "metadata": {}, 117 | "outputs": [], 118 | "source": [ 119 | "nextInd=str(3)" 120 | ] 121 | }, 122 | { 123 | "cell_type": "code", 124 | "execution_count": null, 125 | "metadata": {}, 126 | "outputs": [], 127 | "source": [ 128 | "pp=d(className='android.widget.FrameLayout',resourceId=\"com.sec.android.gallery3d:id/recycler_view_item\",index=nextInd)#,index=\"2\")\n", 129 | "pp.click()\n", 130 | "d.screenshot('saveIMage.png')\n", 131 | "pp=d(className='android.widget.RelativeLayout',resourceId='com.sec.android.gallery3d:id/btn_share')#,index=\"2\")\n", 132 | "pp.click()\n", 133 | "pp=d(className='android.widget.TextView',text='Feed')#,index=\"2\")\n", 134 | "pp.click()\n", 135 | "pp=d(className='android.widget.ImageView',resourceId='com.instagram.android:id/croptype_toggle_button')#,index=\"2\")\n", 136 | "pp.click()\n", 137 | "pp=d(className='android.widget.ImageView',resourceId='com.instagram.android:id/save')#,index=\"2\")\n", 138 | "pp.click()\n", 139 | "pp=d(className='android.widget.TextView',text='Next')#,index=\"2\")\n", 140 | "pp.click()\n", 141 | "pp=d(className='android.widget.EditText')#,index=\"2\")\n", 142 | "pp.click()" 143 | ] 144 | }, 145 | { 146 | "cell_type": "code", 147 | "execution_count": null, 148 | "metadata": {}, 149 | "outputs": [], 150 | "source": [ 151 | "textData='#Jaguar #Jaguars #jaguarftype #jaguarEtype #jaguarcars #jaguarfpace #jaguarxf #JaguarXJ #Jaguariuna #jaguarrussia #JaguarXE #jaguarusa #jaguarftypes #jaguarclub #jaguarclassic #jaguarftyper #jaguarxk #JaguarXJS #jaguarlife #jaguarlandrover #jaguarexperience #jaguarftypesvr #jaguarnation #jaguarpalmbeach #Jaguares #jaguarxkr #jaguarfans #jaguarsvr #jaguarundi #jaguarstyle'" 152 | ] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": null, 157 | "metadata": {}, 158 | "outputs": [], 159 | "source": [ 160 | "pp.set_text('Jaguar from the Mysore Zoo. '+textData)" 161 | ] 162 | }, 163 | { 164 | "cell_type": "code", 165 | "execution_count": null, 166 | "metadata": {}, 167 | "outputs": [], 168 | "source": [ 169 | "pp=d(className='android.widget.TextView',text='Share')#,index=\"2\")\n", 170 | "pp.click()\n", 171 | "\n", 172 | "for i in range(2):\n", 173 | " d.press.back()" 174 | ] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": null, 179 | "metadata": { 180 | "scrolled": true 181 | }, 182 | "outputs": [], 183 | "source": [] 184 | }, 185 | { 186 | "cell_type": "code", 187 | "execution_count": null, 188 | "metadata": {}, 189 | "outputs": [], 190 | "source": [] 191 | }, 192 | { 193 | "cell_type": "code", 194 | "execution_count": null, 195 | "metadata": {}, 196 | "outputs": [], 197 | "source": [] 198 | }, 199 | { 200 | "cell_type": "code", 201 | "execution_count": null, 202 | "metadata": {}, 203 | "outputs": [], 204 | "source": [] 205 | }, 206 | { 207 | "cell_type": "code", 208 | "execution_count": null, 209 | "metadata": {}, 210 | "outputs": [], 211 | "source": [] 212 | }, 213 | { 214 | "cell_type": "code", 215 | "execution_count": null, 216 | "metadata": {}, 217 | "outputs": [], 218 | "source": [] 219 | }, 220 | { 221 | "cell_type": "code", 222 | "execution_count": null, 223 | "metadata": {}, 224 | "outputs": [], 225 | "source": [] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": null, 230 | "metadata": {}, 231 | "outputs": [], 232 | "source": [] 233 | } 234 | ], 235 | "metadata": { 236 | "kernelspec": { 237 | "display_name": "Python 3", 238 | "language": "python", 239 | "name": "python3" 240 | }, 241 | "language_info": { 242 | "codemirror_mode": { 243 | "name": "ipython", 244 | "version": 3 245 | }, 246 | "file_extension": ".py", 247 | "mimetype": "text/x-python", 248 | "name": "python", 249 | "nbconvert_exporter": "python", 250 | "pygments_lexer": "ipython3", 251 | "version": "3.6.8" 252 | } 253 | }, 254 | "nbformat": 4, 255 | "nbformat_minor": 2 256 | } 257 | -------------------------------------------------------------------------------- /recursion/.ipynb_checkpoints/recursion-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## Recursion Functions in Python" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | " A function that calls itself directly (or indirectly) to solve a smaller version of its task until a final call which does not require a self-call is a recursive function." 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 1, 20 | "metadata": {}, 21 | "outputs": [], 22 | "source": [ 23 | "def reFunc(x):\n", 24 | " return reFunc(x)" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 2, 30 | "metadata": {}, 31 | "outputs": [ 32 | { 33 | "ename": "RecursionError", 34 | "evalue": "maximum recursion depth exceeded", 35 | "output_type": "error", 36 | "traceback": [ 37 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 38 | "\u001b[1;31mRecursionError\u001b[0m Traceback (most recent call last)", 39 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mreFunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 40 | "\u001b[1;32m\u001b[0m in \u001b[0;36mreFunc\u001b[1;34m(x)\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mreFunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mreFunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 41 | "... last 1 frames repeated, from the frame below ...\n", 42 | "\u001b[1;32m\u001b[0m in \u001b[0;36mreFunc\u001b[1;34m(x)\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mreFunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mreFunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 43 | "\u001b[1;31mRecursionError\u001b[0m: maximum recursion depth exceeded" 44 | ] 45 | } 46 | ], 47 | "source": [ 48 | "reFunc(2)" 49 | ] 50 | }, 51 | { 52 | "cell_type": "markdown", 53 | "metadata": {}, 54 | "source": [ 55 | "## Stack overflow issue" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": null, 61 | "metadata": {}, 62 | "outputs": [], 63 | "source": [ 64 | "if input value is > 10^4" 65 | ] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "execution_count": null, 70 | "metadata": {}, 71 | "outputs": [], 72 | "source": [] 73 | }, 74 | { 75 | "cell_type": "markdown", 76 | "metadata": {}, 77 | "source": [ 78 | "## Increasing recursion limit" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": null, 84 | "metadata": {}, 85 | "outputs": [], 86 | "source": [ 87 | "import sys\n", 88 | "sys.setrecursionlimit(1500)" 89 | ] 90 | }, 91 | { 92 | "cell_type": "markdown", 93 | "metadata": {}, 94 | "source": [ 95 | "## Example of a factorial" 96 | ] 97 | }, 98 | { 99 | "cell_type": "markdown", 100 | "metadata": {}, 101 | "source": [ 102 | "$$ n! = n* (n-1)! $$" 103 | ] 104 | }, 105 | { 106 | "cell_type": "markdown", 107 | "metadata": {}, 108 | "source": [ 109 | "$$5! = 5* (4* (3 * (2*(1 ))))$$" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": 3, 115 | "metadata": {}, 116 | "outputs": [], 117 | "source": [ 118 | "def factorialCal(x):\n", 119 | "# print(x)\n", 120 | " if x ==0:\n", 121 | " return 1\n", 122 | " else:\n", 123 | " kk=x*(factorialCal(x-1))\n", 124 | "# print (x,kk)\n", 125 | " return kk" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": 4, 131 | "metadata": {}, 132 | "outputs": [ 133 | { 134 | "data": { 135 | "text/plain": [ 136 | "608281864034267560872252163321295376887552831379210240000000000" 137 | ] 138 | }, 139 | "execution_count": 4, 140 | "metadata": {}, 141 | "output_type": "execute_result" 142 | } 143 | ], 144 | "source": [ 145 | "factorialCal(49)" 146 | ] 147 | }, 148 | { 149 | "cell_type": "code", 150 | "execution_count": null, 151 | "metadata": {}, 152 | "outputs": [], 153 | "source": [] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": null, 158 | "metadata": {}, 159 | "outputs": [], 160 | "source": [] 161 | }, 162 | { 163 | "cell_type": "code", 164 | "execution_count": null, 165 | "metadata": {}, 166 | "outputs": [], 167 | "source": [] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": null, 172 | "metadata": {}, 173 | "outputs": [], 174 | "source": [] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": 12, 179 | "metadata": {}, 180 | "outputs": [], 181 | "source": [ 182 | "def fatcorialTail(x,xVal):\n", 183 | " if x==0:\n", 184 | " return xVal\n", 185 | " return fatcorialTail(x-1,x*xVal)" 186 | ] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": 13, 191 | "metadata": {}, 192 | "outputs": [], 193 | "source": [ 194 | "def factVal(x): \n", 195 | " return fatcorialTail(x, 1) " 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": 14, 201 | "metadata": {}, 202 | "outputs": [ 203 | { 204 | "data": { 205 | "text/plain": [ 206 | "120" 207 | ] 208 | }, 209 | "execution_count": 14, 210 | "metadata": {}, 211 | "output_type": "execute_result" 212 | } 213 | ], 214 | "source": [ 215 | "factVal(5)" 216 | ] 217 | }, 218 | { 219 | "cell_type": "code", 220 | "execution_count": null, 221 | "metadata": {}, 222 | "outputs": [], 223 | "source": [] 224 | } 225 | ], 226 | "metadata": { 227 | "kernelspec": { 228 | "display_name": "Python 3", 229 | "language": "python", 230 | "name": "python3" 231 | }, 232 | "language_info": { 233 | "codemirror_mode": { 234 | "name": "ipython", 235 | "version": 3 236 | }, 237 | "file_extension": ".py", 238 | "mimetype": "text/x-python", 239 | "name": "python", 240 | "nbconvert_exporter": "python", 241 | "pygments_lexer": "ipython3", 242 | "version": "3.6.9" 243 | } 244 | }, 245 | "nbformat": 4, 246 | "nbformat_minor": 2 247 | } 248 | -------------------------------------------------------------------------------- /Python Programming Notebooks/Zip function in Python.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Zip " 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "zip function in python takes iterable elements as input, and returns iterator object as return. If Python zip function gets no iterable elements, it returns an empty iterator." 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 1, 20 | "metadata": {}, 21 | "outputs": [], 22 | "source": [ 23 | "a=range(20)\n", 24 | "b=range(20,40)" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 6, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "zipVar=zip(a,b)" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 7, 39 | "metadata": {}, 40 | "outputs": [ 41 | { 42 | "data": { 43 | "text/plain": [ 44 | "" 45 | ] 46 | }, 47 | "execution_count": 7, 48 | "metadata": {}, 49 | "output_type": "execute_result" 50 | } 51 | ], 52 | "source": [ 53 | "zipVar" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": 8, 59 | "metadata": {}, 60 | "outputs": [], 61 | "source": [ 62 | "# list(zipVar)" 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": 30, 68 | "metadata": {}, 69 | "outputs": [ 70 | { 71 | "ename": "StopIteration", 72 | "evalue": "", 73 | "output_type": "error", 74 | "traceback": [ 75 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 76 | "\u001b[1;31mStopIteration\u001b[0m Traceback (most recent call last)", 77 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mnext\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mzipVar\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 78 | "\u001b[1;31mStopIteration\u001b[0m: " 79 | ] 80 | } 81 | ], 82 | "source": [ 83 | "next(zipVar)" 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": 31, 89 | "metadata": {}, 90 | "outputs": [ 91 | { 92 | "data": { 93 | "text/plain": [ 94 | "[]" 95 | ] 96 | }, 97 | "execution_count": 31, 98 | "metadata": {}, 99 | "output_type": "execute_result" 100 | } 101 | ], 102 | "source": [ 103 | "list(zipVar)" 104 | ] 105 | }, 106 | { 107 | "cell_type": "markdown", 108 | "metadata": {}, 109 | "source": [ 110 | "## Zip with no values" 111 | ] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "execution_count": 32, 116 | "metadata": {}, 117 | "outputs": [], 118 | "source": [ 119 | "emptyZip=zip([])" 120 | ] 121 | }, 122 | { 123 | "cell_type": "code", 124 | "execution_count": 33, 125 | "metadata": {}, 126 | "outputs": [ 127 | { 128 | "data": { 129 | "text/plain": [ 130 | "" 131 | ] 132 | }, 133 | "execution_count": 33, 134 | "metadata": {}, 135 | "output_type": "execute_result" 136 | } 137 | ], 138 | "source": [ 139 | "emptyZip" 140 | ] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "execution_count": 34, 145 | "metadata": {}, 146 | "outputs": [ 147 | { 148 | "data": { 149 | "text/plain": [ 150 | "[]" 151 | ] 152 | }, 153 | "execution_count": 34, 154 | "metadata": {}, 155 | "output_type": "execute_result" 156 | } 157 | ], 158 | "source": [ 159 | "list(emptyZip)" 160 | ] 161 | }, 162 | { 163 | "cell_type": "markdown", 164 | "metadata": {}, 165 | "source": [ 166 | "## Zip does not work with unequal lengths?" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": 35, 172 | "metadata": {}, 173 | "outputs": [], 174 | "source": [ 175 | "a=range(20)\n", 176 | "b=range(20,39)" 177 | ] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": 36, 182 | "metadata": {}, 183 | "outputs": [], 184 | "source": [ 185 | "zipVar2=zip(a,b)" 186 | ] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": 37, 191 | "metadata": {}, 192 | "outputs": [ 193 | { 194 | "data": { 195 | "text/plain": [ 196 | "19" 197 | ] 198 | }, 199 | "execution_count": 37, 200 | "metadata": {}, 201 | "output_type": "execute_result" 202 | } 203 | ], 204 | "source": [ 205 | "len(list(zipVar2))" 206 | ] 207 | }, 208 | { 209 | "cell_type": "markdown", 210 | "metadata": {}, 211 | "source": [ 212 | "## Can I pass single sequence in zip" 213 | ] 214 | }, 215 | { 216 | "cell_type": "code", 217 | "execution_count": 38, 218 | "metadata": {}, 219 | "outputs": [], 220 | "source": [ 221 | "singleZip=zip([1,2,3])" 222 | ] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": 39, 227 | "metadata": {}, 228 | "outputs": [ 229 | { 230 | "data": { 231 | "text/plain": [ 232 | "[(1,), (2,), (3,)]" 233 | ] 234 | }, 235 | "execution_count": 39, 236 | "metadata": {}, 237 | "output_type": "execute_result" 238 | } 239 | ], 240 | "source": [ 241 | "list(singleZip)" 242 | ] 243 | }, 244 | { 245 | "cell_type": "markdown", 246 | "metadata": {}, 247 | "source": [ 248 | "## Where it can be useful?" 249 | ] 250 | }, 251 | { 252 | "cell_type": "markdown", 253 | "metadata": {}, 254 | "source": [ 255 | "### Iterating over multiple lists which needs to be computed together" 256 | ] 257 | }, 258 | { 259 | "cell_type": "code", 260 | "execution_count": 40, 261 | "metadata": {}, 262 | "outputs": [], 263 | "source": [ 264 | "revenue=[100,200,300,2003,400,500]\n", 265 | "expenditure=[122,123,250,1500,344,455]" 266 | ] 267 | }, 268 | { 269 | "cell_type": "code", 270 | "execution_count": 41, 271 | "metadata": {}, 272 | "outputs": [ 273 | { 274 | "name": "stdout", 275 | "output_type": "stream", 276 | "text": [ 277 | "profit in the transaction is -22\n", 278 | "profit in the transaction is 77\n", 279 | "profit in the transaction is 50\n", 280 | "profit in the transaction is 503\n", 281 | "profit in the transaction is 56\n", 282 | "profit in the transaction is 45\n" 283 | ] 284 | } 285 | ], 286 | "source": [ 287 | "for i,j in zip(revenue,expenditure):\n", 288 | " print ('profit in the transaction is ',i-j)" 289 | ] 290 | }, 291 | { 292 | "cell_type": "markdown", 293 | "metadata": {}, 294 | "source": [ 295 | "### Same operation can be done in multiple dictionaries" 296 | ] 297 | }, 298 | { 299 | "cell_type": "markdown", 300 | "metadata": {}, 301 | "source": [ 302 | "### Zip and UNzip" 303 | ] 304 | }, 305 | { 306 | "cell_type": "code", 307 | "execution_count": 42, 308 | "metadata": {}, 309 | "outputs": [], 310 | "source": [ 311 | "zippedData=[(1,'a'),(2,'a2'),(3,'a3')]" 312 | ] 313 | }, 314 | { 315 | "cell_type": "code", 316 | "execution_count": 43, 317 | "metadata": {}, 318 | "outputs": [], 319 | "source": [ 320 | "unzipped=zip(*zippedData)" 321 | ] 322 | }, 323 | { 324 | "cell_type": "code", 325 | "execution_count": 44, 326 | "metadata": {}, 327 | "outputs": [ 328 | { 329 | "data": { 330 | "text/plain": [ 331 | "[(1, 2, 3), ('a', 'a2', 'a3')]" 332 | ] 333 | }, 334 | "execution_count": 44, 335 | "metadata": {}, 336 | "output_type": "execute_result" 337 | } 338 | ], 339 | "source": [ 340 | "list(unzipped)" 341 | ] 342 | }, 343 | { 344 | "cell_type": "code", 345 | "execution_count": null, 346 | "metadata": {}, 347 | "outputs": [], 348 | "source": [] 349 | } 350 | ], 351 | "metadata": { 352 | "kernelspec": { 353 | "display_name": "Python 3", 354 | "language": "python", 355 | "name": "python3" 356 | }, 357 | "language_info": { 358 | "codemirror_mode": { 359 | "name": "ipython", 360 | "version": 3 361 | }, 362 | "file_extension": ".py", 363 | "mimetype": "text/x-python", 364 | "name": "python", 365 | "nbconvert_exporter": "python", 366 | "pygments_lexer": "ipython3", 367 | "version": "3.6.9" 368 | } 369 | }, 370 | "nbformat": 4, 371 | "nbformat_minor": 2 372 | } 373 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/Zip function in Python-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Zip " 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "zip function in python takes iterable elements as input, and returns iterator object as return. If Python zip function gets no iterable elements, it returns an empty iterator." 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 1, 20 | "metadata": {}, 21 | "outputs": [], 22 | "source": [ 23 | "a=range(20)\n", 24 | "b=range(20,40)" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 6, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "zipVar=zip(a,b)" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 7, 39 | "metadata": {}, 40 | "outputs": [ 41 | { 42 | "data": { 43 | "text/plain": [ 44 | "" 45 | ] 46 | }, 47 | "execution_count": 7, 48 | "metadata": {}, 49 | "output_type": "execute_result" 50 | } 51 | ], 52 | "source": [ 53 | "zipVar" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": 8, 59 | "metadata": {}, 60 | "outputs": [], 61 | "source": [ 62 | "# list(zipVar)" 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": 30, 68 | "metadata": {}, 69 | "outputs": [ 70 | { 71 | "ename": "StopIteration", 72 | "evalue": "", 73 | "output_type": "error", 74 | "traceback": [ 75 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 76 | "\u001b[1;31mStopIteration\u001b[0m Traceback (most recent call last)", 77 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mnext\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mzipVar\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 78 | "\u001b[1;31mStopIteration\u001b[0m: " 79 | ] 80 | } 81 | ], 82 | "source": [ 83 | "next(zipVar)" 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": 31, 89 | "metadata": {}, 90 | "outputs": [ 91 | { 92 | "data": { 93 | "text/plain": [ 94 | "[]" 95 | ] 96 | }, 97 | "execution_count": 31, 98 | "metadata": {}, 99 | "output_type": "execute_result" 100 | } 101 | ], 102 | "source": [ 103 | "list(zipVar)" 104 | ] 105 | }, 106 | { 107 | "cell_type": "markdown", 108 | "metadata": {}, 109 | "source": [ 110 | "## Zip with no values" 111 | ] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "execution_count": 32, 116 | "metadata": {}, 117 | "outputs": [], 118 | "source": [ 119 | "emptyZip=zip([])" 120 | ] 121 | }, 122 | { 123 | "cell_type": "code", 124 | "execution_count": 33, 125 | "metadata": {}, 126 | "outputs": [ 127 | { 128 | "data": { 129 | "text/plain": [ 130 | "" 131 | ] 132 | }, 133 | "execution_count": 33, 134 | "metadata": {}, 135 | "output_type": "execute_result" 136 | } 137 | ], 138 | "source": [ 139 | "emptyZip" 140 | ] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "execution_count": 34, 145 | "metadata": {}, 146 | "outputs": [ 147 | { 148 | "data": { 149 | "text/plain": [ 150 | "[]" 151 | ] 152 | }, 153 | "execution_count": 34, 154 | "metadata": {}, 155 | "output_type": "execute_result" 156 | } 157 | ], 158 | "source": [ 159 | "list(emptyZip)" 160 | ] 161 | }, 162 | { 163 | "cell_type": "markdown", 164 | "metadata": {}, 165 | "source": [ 166 | "## Zip does not work with unequal lengths?" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": 35, 172 | "metadata": {}, 173 | "outputs": [], 174 | "source": [ 175 | "a=range(20)\n", 176 | "b=range(20,39)" 177 | ] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": 36, 182 | "metadata": {}, 183 | "outputs": [], 184 | "source": [ 185 | "zipVar2=zip(a,b)" 186 | ] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": 37, 191 | "metadata": {}, 192 | "outputs": [ 193 | { 194 | "data": { 195 | "text/plain": [ 196 | "19" 197 | ] 198 | }, 199 | "execution_count": 37, 200 | "metadata": {}, 201 | "output_type": "execute_result" 202 | } 203 | ], 204 | "source": [ 205 | "len(list(zipVar2))" 206 | ] 207 | }, 208 | { 209 | "cell_type": "markdown", 210 | "metadata": {}, 211 | "source": [ 212 | "## Can I pass single sequence in zip" 213 | ] 214 | }, 215 | { 216 | "cell_type": "code", 217 | "execution_count": 38, 218 | "metadata": {}, 219 | "outputs": [], 220 | "source": [ 221 | "singleZip=zip([1,2,3])" 222 | ] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": 39, 227 | "metadata": {}, 228 | "outputs": [ 229 | { 230 | "data": { 231 | "text/plain": [ 232 | "[(1,), (2,), (3,)]" 233 | ] 234 | }, 235 | "execution_count": 39, 236 | "metadata": {}, 237 | "output_type": "execute_result" 238 | } 239 | ], 240 | "source": [ 241 | "list(singleZip)" 242 | ] 243 | }, 244 | { 245 | "cell_type": "markdown", 246 | "metadata": {}, 247 | "source": [ 248 | "## Where it can be useful?" 249 | ] 250 | }, 251 | { 252 | "cell_type": "markdown", 253 | "metadata": {}, 254 | "source": [ 255 | "### Iterating over multiple lists which needs to be computed together" 256 | ] 257 | }, 258 | { 259 | "cell_type": "code", 260 | "execution_count": 40, 261 | "metadata": {}, 262 | "outputs": [], 263 | "source": [ 264 | "revenue=[100,200,300,2003,400,500]\n", 265 | "expenditure=[122,123,250,1500,344,455]" 266 | ] 267 | }, 268 | { 269 | "cell_type": "code", 270 | "execution_count": 41, 271 | "metadata": {}, 272 | "outputs": [ 273 | { 274 | "name": "stdout", 275 | "output_type": "stream", 276 | "text": [ 277 | "profit in the transaction is -22\n", 278 | "profit in the transaction is 77\n", 279 | "profit in the transaction is 50\n", 280 | "profit in the transaction is 503\n", 281 | "profit in the transaction is 56\n", 282 | "profit in the transaction is 45\n" 283 | ] 284 | } 285 | ], 286 | "source": [ 287 | "for i,j in zip(revenue,expenditure):\n", 288 | " print ('profit in the transaction is ',i-j)" 289 | ] 290 | }, 291 | { 292 | "cell_type": "markdown", 293 | "metadata": {}, 294 | "source": [ 295 | "### Same operation can be done in multiple dictionaries" 296 | ] 297 | }, 298 | { 299 | "cell_type": "markdown", 300 | "metadata": {}, 301 | "source": [ 302 | "### Zip and UNzip" 303 | ] 304 | }, 305 | { 306 | "cell_type": "code", 307 | "execution_count": 42, 308 | "metadata": {}, 309 | "outputs": [], 310 | "source": [ 311 | "zippedData=[(1,'a'),(2,'a2'),(3,'a3')]" 312 | ] 313 | }, 314 | { 315 | "cell_type": "code", 316 | "execution_count": 43, 317 | "metadata": {}, 318 | "outputs": [], 319 | "source": [ 320 | "unzipped=zip(*zippedData)" 321 | ] 322 | }, 323 | { 324 | "cell_type": "code", 325 | "execution_count": 44, 326 | "metadata": {}, 327 | "outputs": [ 328 | { 329 | "data": { 330 | "text/plain": [ 331 | "[(1, 2, 3), ('a', 'a2', 'a3')]" 332 | ] 333 | }, 334 | "execution_count": 44, 335 | "metadata": {}, 336 | "output_type": "execute_result" 337 | } 338 | ], 339 | "source": [ 340 | "list(unzipped)" 341 | ] 342 | }, 343 | { 344 | "cell_type": "code", 345 | "execution_count": null, 346 | "metadata": {}, 347 | "outputs": [], 348 | "source": [] 349 | } 350 | ], 351 | "metadata": { 352 | "kernelspec": { 353 | "display_name": "Python 3", 354 | "language": "python", 355 | "name": "python3" 356 | }, 357 | "language_info": { 358 | "codemirror_mode": { 359 | "name": "ipython", 360 | "version": 3 361 | }, 362 | "file_extension": ".py", 363 | "mimetype": "text/x-python", 364 | "name": "python", 365 | "nbconvert_exporter": "python", 366 | "pygments_lexer": "ipython3", 367 | "version": "3.6.9" 368 | } 369 | }, 370 | "nbformat": 4, 371 | "nbformat_minor": 2 372 | } 373 | -------------------------------------------------------------------------------- /instagramAutomation/insta Uplaod images-Self.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 13, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from uiautomator import device as d\n", 10 | "from uiautomator import Device\n", 11 | "from time import sleep\n", 12 | "import os" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 14, 18 | "metadata": {}, 19 | "outputs": [ 20 | { 21 | "data": { 22 | "text/plain": [ 23 | "{'currentPackageName': 'com.sec.android.app.launcher',\n", 24 | " 'displayHeight': 2058,\n", 25 | " 'displayRotation': 0,\n", 26 | " 'displaySizeDpX': 320,\n", 27 | " 'displaySizeDpY': 658,\n", 28 | " 'displayWidth': 1080,\n", 29 | " 'productName': 'starqlteue',\n", 30 | " 'screenOn': True,\n", 31 | " 'sdkInt': 29,\n", 32 | " 'naturalOrientation': True}" 33 | ] 34 | }, 35 | "execution_count": 14, 36 | "metadata": {}, 37 | "output_type": "execute_result" 38 | } 39 | ], 40 | "source": [ 41 | "d.info" 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "execution_count": 15, 47 | "metadata": {}, 48 | "outputs": [ 49 | { 50 | "data": { 51 | "text/plain": [ 52 | "{'currentPackageName': 'com.sec.android.app.launcher',\n", 53 | " 'displayHeight': 2058,\n", 54 | " 'displayRotation': 0,\n", 55 | " 'displaySizeDpX': 320,\n", 56 | " 'displaySizeDpY': 658,\n", 57 | " 'displayWidth': 1080,\n", 58 | " 'productName': 'starqlteue',\n", 59 | " 'screenOn': True,\n", 60 | " 'sdkInt': 29,\n", 61 | " 'naturalOrientation': True}" 62 | ] 63 | }, 64 | "execution_count": 15, 65 | "metadata": {}, 66 | "output_type": "execute_result" 67 | } 68 | ], 69 | "source": [ 70 | "d.infod = Device('375637504c583398')\n", 71 | "\n", 72 | "d.info" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": 16, 78 | "metadata": {}, 79 | "outputs": [], 80 | "source": [ 81 | "# d.dump('someHier.xml')" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": 17, 87 | "metadata": {}, 88 | "outputs": [ 89 | { 90 | "data": { 91 | "text/plain": [ 92 | "True" 93 | ] 94 | }, 95 | "execution_count": 17, 96 | "metadata": {}, 97 | "output_type": "execute_result" 98 | } 99 | ], 100 | "source": [ 101 | "d.press.home()\n", 102 | "sx, sy, ex, ey= 100 ,150,100,450\n", 103 | "d.swipe(sx, sy, ex, ey, steps=5)" 104 | ] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "execution_count": 18, 109 | "metadata": {}, 110 | "outputs": [ 111 | { 112 | "data": { 113 | "text/plain": [ 114 | "True" 115 | ] 116 | }, 117 | "execution_count": 18, 118 | "metadata": {}, 119 | "output_type": "execute_result" 120 | } 121 | ], 122 | "source": [ 123 | "instaVal=d(text='Gallery', className='android.widget.TextView')\n", 124 | "instaVal.click()" 125 | ] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "execution_count": 19, 130 | "metadata": {}, 131 | "outputs": [ 132 | { 133 | "data": { 134 | "text/plain": [ 135 | "True" 136 | ] 137 | }, 138 | "execution_count": 19, 139 | "metadata": {}, 140 | "output_type": "execute_result" 141 | } 142 | ], 143 | "source": [ 144 | "sx, sy, ex, ey= 560,800,560 ,50\n", 145 | "d.swipe(sx, sy, ex, ey, steps=10)" 146 | ] 147 | }, 148 | { 149 | "cell_type": "code", 150 | "execution_count": 20, 151 | "metadata": {}, 152 | "outputs": [ 153 | { 154 | "data": { 155 | "text/plain": [ 156 | "True" 157 | ] 158 | }, 159 | "execution_count": 20, 160 | "metadata": {}, 161 | "output_type": "execute_result" 162 | } 163 | ], 164 | "source": [ 165 | "pp=d(className='android.widget.TextView',text='Downloads')#,index=\"2\")\n", 166 | "pp.click()" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": 21, 172 | "metadata": {}, 173 | "outputs": [], 174 | "source": [ 175 | "textData='#orchid #orchids #orchidee #orchidea #orchidlover #orchidsofinstagram #Orchideen #orchidshow #orchidaceae #orchidworld #orchidstagram #orchidlove #orchidshare #OrchidLovers #orchidgarden #orchidmag #orchidflower #orchide #orchidspecies #orchidbeauty #orchideuro #orchidisland #orchidoftheday #orchidfan #orchidsinbloom #orchidtattoo #orchideas #orchidflowers #orchidphotography #orchidacea'" 176 | ] 177 | }, 178 | { 179 | "cell_type": "code", 180 | "execution_count": 22, 181 | "metadata": {}, 182 | "outputs": [], 183 | "source": [ 184 | "togo=[0,1,4,5]\n", 185 | "for i in togo:\n", 186 | " nextInd=str(i)\n", 187 | " pp=d(className='android.widget.FrameLayout',resourceId=\"com.sec.android.gallery3d:id/recycler_view_item\",index=nextInd)#,index=\"2\")\n", 188 | " pp.click()\n", 189 | " # d.screenshot('saveIMage.png')\n", 190 | " pp=d(className='android.widget.RelativeLayout',resourceId='com.sec.android.gallery3d:id/btn_share')#,index=\"2\")\n", 191 | " pp.click()\n", 192 | " pp=d(className='android.widget.TextView',text='Feed')#,index=\"2\")\n", 193 | " pp.click()\n", 194 | " pp=d(className='android.widget.ImageView',resourceId='com.instagram.android:id/croptype_toggle_button')#,index=\"2\")\n", 195 | " pp.click()\n", 196 | " pp=d(className='android.widget.ImageView',resourceId='com.instagram.android:id/save')#,index=\"2\")\n", 197 | " pp.click()\n", 198 | " pp=d(className='android.widget.TextView',text='Next')#,index=\"2\")\n", 199 | " pp.click()\n", 200 | " pp=d(className='android.widget.EditText')#,index=\"2\")\n", 201 | " pp.click()\n", 202 | " pp.set_text('Wilhelma Zoo, Orchid garden, Botonical Garden. '+textData)\n", 203 | " pp=d(className='android.widget.TextView',text='Share')#,index=\"2\")\n", 204 | " pp.click()\n", 205 | "\n", 206 | " for i in range(2):\n", 207 | " d.press.back()" 208 | ] 209 | }, 210 | { 211 | "cell_type": "code", 212 | "execution_count": 10, 213 | "metadata": {}, 214 | "outputs": [ 215 | { 216 | "data": { 217 | "text/plain": [ 218 | "True" 219 | ] 220 | }, 221 | "execution_count": 10, 222 | "metadata": {}, 223 | "output_type": "execute_result" 224 | } 225 | ], 226 | "source": [] 227 | }, 228 | { 229 | "cell_type": "code", 230 | "execution_count": 17, 231 | "metadata": {}, 232 | "outputs": [], 233 | "source": [] 234 | }, 235 | { 236 | "cell_type": "code", 237 | "execution_count": 18, 238 | "metadata": {}, 239 | "outputs": [ 240 | { 241 | "data": { 242 | "text/plain": [ 243 | "True" 244 | ] 245 | }, 246 | "execution_count": 18, 247 | "metadata": {}, 248 | "output_type": "execute_result" 249 | } 250 | ], 251 | "source": [] 252 | }, 253 | { 254 | "cell_type": "code", 255 | "execution_count": null, 256 | "metadata": {}, 257 | "outputs": [], 258 | "source": [] 259 | }, 260 | { 261 | "cell_type": "code", 262 | "execution_count": null, 263 | "metadata": { 264 | "scrolled": true 265 | }, 266 | "outputs": [], 267 | "source": [] 268 | }, 269 | { 270 | "cell_type": "code", 271 | "execution_count": null, 272 | "metadata": {}, 273 | "outputs": [], 274 | "source": [] 275 | }, 276 | { 277 | "cell_type": "code", 278 | "execution_count": null, 279 | "metadata": {}, 280 | "outputs": [], 281 | "source": [] 282 | }, 283 | { 284 | "cell_type": "code", 285 | "execution_count": null, 286 | "metadata": {}, 287 | "outputs": [], 288 | "source": [] 289 | }, 290 | { 291 | "cell_type": "code", 292 | "execution_count": null, 293 | "metadata": {}, 294 | "outputs": [], 295 | "source": [] 296 | }, 297 | { 298 | "cell_type": "code", 299 | "execution_count": null, 300 | "metadata": {}, 301 | "outputs": [], 302 | "source": [] 303 | }, 304 | { 305 | "cell_type": "code", 306 | "execution_count": null, 307 | "metadata": {}, 308 | "outputs": [], 309 | "source": [] 310 | }, 311 | { 312 | "cell_type": "code", 313 | "execution_count": null, 314 | "metadata": {}, 315 | "outputs": [], 316 | "source": [] 317 | } 318 | ], 319 | "metadata": { 320 | "kernelspec": { 321 | "display_name": "Python 3", 322 | "language": "python", 323 | "name": "python3" 324 | }, 325 | "language_info": { 326 | "codemirror_mode": { 327 | "name": "ipython", 328 | "version": 3 329 | }, 330 | "file_extension": ".py", 331 | "mimetype": "text/x-python", 332 | "name": "python", 333 | "nbconvert_exporter": "python", 334 | "pygments_lexer": "ipython3", 335 | "version": "3.6.9" 336 | } 337 | }, 338 | "nbformat": 4, 339 | "nbformat_minor": 2 340 | } 341 | -------------------------------------------------------------------------------- /instagramAutomation/.ipynb_checkpoints/insta Uplaod images-Self-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 13, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from uiautomator import device as d\n", 10 | "from uiautomator import Device\n", 11 | "from time import sleep\n", 12 | "import os" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 14, 18 | "metadata": {}, 19 | "outputs": [ 20 | { 21 | "data": { 22 | "text/plain": [ 23 | "{'currentPackageName': 'com.sec.android.app.launcher',\n", 24 | " 'displayHeight': 2058,\n", 25 | " 'displayRotation': 0,\n", 26 | " 'displaySizeDpX': 320,\n", 27 | " 'displaySizeDpY': 658,\n", 28 | " 'displayWidth': 1080,\n", 29 | " 'productName': 'starqlteue',\n", 30 | " 'screenOn': True,\n", 31 | " 'sdkInt': 29,\n", 32 | " 'naturalOrientation': True}" 33 | ] 34 | }, 35 | "execution_count": 14, 36 | "metadata": {}, 37 | "output_type": "execute_result" 38 | } 39 | ], 40 | "source": [ 41 | "d.info" 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "execution_count": 15, 47 | "metadata": {}, 48 | "outputs": [ 49 | { 50 | "data": { 51 | "text/plain": [ 52 | "{'currentPackageName': 'com.sec.android.app.launcher',\n", 53 | " 'displayHeight': 2058,\n", 54 | " 'displayRotation': 0,\n", 55 | " 'displaySizeDpX': 320,\n", 56 | " 'displaySizeDpY': 658,\n", 57 | " 'displayWidth': 1080,\n", 58 | " 'productName': 'starqlteue',\n", 59 | " 'screenOn': True,\n", 60 | " 'sdkInt': 29,\n", 61 | " 'naturalOrientation': True}" 62 | ] 63 | }, 64 | "execution_count": 15, 65 | "metadata": {}, 66 | "output_type": "execute_result" 67 | } 68 | ], 69 | "source": [ 70 | "d.infod = Device('375637504c583398')\n", 71 | "\n", 72 | "d.info" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": 16, 78 | "metadata": {}, 79 | "outputs": [], 80 | "source": [ 81 | "# d.dump('someHier.xml')" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": 17, 87 | "metadata": {}, 88 | "outputs": [ 89 | { 90 | "data": { 91 | "text/plain": [ 92 | "True" 93 | ] 94 | }, 95 | "execution_count": 17, 96 | "metadata": {}, 97 | "output_type": "execute_result" 98 | } 99 | ], 100 | "source": [ 101 | "d.press.home()\n", 102 | "sx, sy, ex, ey= 100 ,150,100,450\n", 103 | "d.swipe(sx, sy, ex, ey, steps=5)" 104 | ] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "execution_count": 18, 109 | "metadata": {}, 110 | "outputs": [ 111 | { 112 | "data": { 113 | "text/plain": [ 114 | "True" 115 | ] 116 | }, 117 | "execution_count": 18, 118 | "metadata": {}, 119 | "output_type": "execute_result" 120 | } 121 | ], 122 | "source": [ 123 | "instaVal=d(text='Gallery', className='android.widget.TextView')\n", 124 | "instaVal.click()" 125 | ] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "execution_count": 19, 130 | "metadata": {}, 131 | "outputs": [ 132 | { 133 | "data": { 134 | "text/plain": [ 135 | "True" 136 | ] 137 | }, 138 | "execution_count": 19, 139 | "metadata": {}, 140 | "output_type": "execute_result" 141 | } 142 | ], 143 | "source": [ 144 | "sx, sy, ex, ey= 560,800,560 ,50\n", 145 | "d.swipe(sx, sy, ex, ey, steps=10)" 146 | ] 147 | }, 148 | { 149 | "cell_type": "code", 150 | "execution_count": 20, 151 | "metadata": {}, 152 | "outputs": [ 153 | { 154 | "data": { 155 | "text/plain": [ 156 | "True" 157 | ] 158 | }, 159 | "execution_count": 20, 160 | "metadata": {}, 161 | "output_type": "execute_result" 162 | } 163 | ], 164 | "source": [ 165 | "pp=d(className='android.widget.TextView',text='Downloads')#,index=\"2\")\n", 166 | "pp.click()" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": 21, 172 | "metadata": {}, 173 | "outputs": [], 174 | "source": [ 175 | "textData='#orchid #orchids #orchidee #orchidea #orchidlover #orchidsofinstagram #Orchideen #orchidshow #orchidaceae #orchidworld #orchidstagram #orchidlove #orchidshare #OrchidLovers #orchidgarden #orchidmag #orchidflower #orchide #orchidspecies #orchidbeauty #orchideuro #orchidisland #orchidoftheday #orchidfan #orchidsinbloom #orchidtattoo #orchideas #orchidflowers #orchidphotography #orchidacea'" 176 | ] 177 | }, 178 | { 179 | "cell_type": "code", 180 | "execution_count": 22, 181 | "metadata": {}, 182 | "outputs": [], 183 | "source": [ 184 | "togo=[0,1,4,5]\n", 185 | "for i in togo:\n", 186 | " nextInd=str(i)\n", 187 | " pp=d(className='android.widget.FrameLayout',resourceId=\"com.sec.android.gallery3d:id/recycler_view_item\",index=nextInd)#,index=\"2\")\n", 188 | " pp.click()\n", 189 | " # d.screenshot('saveIMage.png')\n", 190 | " pp=d(className='android.widget.RelativeLayout',resourceId='com.sec.android.gallery3d:id/btn_share')#,index=\"2\")\n", 191 | " pp.click()\n", 192 | " pp=d(className='android.widget.TextView',text='Feed')#,index=\"2\")\n", 193 | " pp.click()\n", 194 | " pp=d(className='android.widget.ImageView',resourceId='com.instagram.android:id/croptype_toggle_button')#,index=\"2\")\n", 195 | " pp.click()\n", 196 | " pp=d(className='android.widget.ImageView',resourceId='com.instagram.android:id/save')#,index=\"2\")\n", 197 | " pp.click()\n", 198 | " pp=d(className='android.widget.TextView',text='Next')#,index=\"2\")\n", 199 | " pp.click()\n", 200 | " pp=d(className='android.widget.EditText')#,index=\"2\")\n", 201 | " pp.click()\n", 202 | " pp.set_text('Wilhelma Zoo, Orchid garden, Botonical Garden. '+textData)\n", 203 | " pp=d(className='android.widget.TextView',text='Share')#,index=\"2\")\n", 204 | " pp.click()\n", 205 | "\n", 206 | " for i in range(2):\n", 207 | " d.press.back()" 208 | ] 209 | }, 210 | { 211 | "cell_type": "code", 212 | "execution_count": 10, 213 | "metadata": {}, 214 | "outputs": [ 215 | { 216 | "data": { 217 | "text/plain": [ 218 | "True" 219 | ] 220 | }, 221 | "execution_count": 10, 222 | "metadata": {}, 223 | "output_type": "execute_result" 224 | } 225 | ], 226 | "source": [] 227 | }, 228 | { 229 | "cell_type": "code", 230 | "execution_count": 17, 231 | "metadata": {}, 232 | "outputs": [], 233 | "source": [] 234 | }, 235 | { 236 | "cell_type": "code", 237 | "execution_count": 18, 238 | "metadata": {}, 239 | "outputs": [ 240 | { 241 | "data": { 242 | "text/plain": [ 243 | "True" 244 | ] 245 | }, 246 | "execution_count": 18, 247 | "metadata": {}, 248 | "output_type": "execute_result" 249 | } 250 | ], 251 | "source": [] 252 | }, 253 | { 254 | "cell_type": "code", 255 | "execution_count": null, 256 | "metadata": {}, 257 | "outputs": [], 258 | "source": [] 259 | }, 260 | { 261 | "cell_type": "code", 262 | "execution_count": null, 263 | "metadata": { 264 | "scrolled": true 265 | }, 266 | "outputs": [], 267 | "source": [] 268 | }, 269 | { 270 | "cell_type": "code", 271 | "execution_count": null, 272 | "metadata": {}, 273 | "outputs": [], 274 | "source": [] 275 | }, 276 | { 277 | "cell_type": "code", 278 | "execution_count": null, 279 | "metadata": {}, 280 | "outputs": [], 281 | "source": [] 282 | }, 283 | { 284 | "cell_type": "code", 285 | "execution_count": null, 286 | "metadata": {}, 287 | "outputs": [], 288 | "source": [] 289 | }, 290 | { 291 | "cell_type": "code", 292 | "execution_count": null, 293 | "metadata": {}, 294 | "outputs": [], 295 | "source": [] 296 | }, 297 | { 298 | "cell_type": "code", 299 | "execution_count": null, 300 | "metadata": {}, 301 | "outputs": [], 302 | "source": [] 303 | }, 304 | { 305 | "cell_type": "code", 306 | "execution_count": null, 307 | "metadata": {}, 308 | "outputs": [], 309 | "source": [] 310 | }, 311 | { 312 | "cell_type": "code", 313 | "execution_count": null, 314 | "metadata": {}, 315 | "outputs": [], 316 | "source": [] 317 | } 318 | ], 319 | "metadata": { 320 | "kernelspec": { 321 | "display_name": "Python 3", 322 | "language": "python", 323 | "name": "python3" 324 | }, 325 | "language_info": { 326 | "codemirror_mode": { 327 | "name": "ipython", 328 | "version": 3 329 | }, 330 | "file_extension": ".py", 331 | "mimetype": "text/x-python", 332 | "name": "python", 333 | "nbconvert_exporter": "python", 334 | "pygments_lexer": "ipython3", 335 | "version": "3.6.9" 336 | } 337 | }, 338 | "nbformat": 4, 339 | "nbformat_minor": 2 340 | } 341 | -------------------------------------------------------------------------------- /mongodb/mongodb connection.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "Collecting pymongo\n", 13 | " Downloading https://files.pythonhosted.org/packages/40/bc/015c54f2a26cba27763a0ce6a11d0ea6c647967d96ac6ae19e02c6598094/pymongo-3.10.1-cp36-cp36m-win_amd64.whl (354kB)\n", 14 | "Installing collected packages: pymongo\n", 15 | "Successfully installed pymongo-3.10.1\n" 16 | ] 17 | } 18 | ], 19 | "source": [ 20 | "!pip install pymongo" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": 3, 26 | "metadata": {}, 27 | "outputs": [], 28 | "source": [ 29 | "import pymongo" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": 1, 35 | "metadata": {}, 36 | "outputs": [], 37 | "source": [ 38 | "from pymongo import MongoClient\n", 39 | "# client = MongoClient()" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 2, 45 | "metadata": {}, 46 | "outputs": [], 47 | "source": [ 48 | "client = MongoClient('localhost', 27017)" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 3, 54 | "metadata": {}, 55 | "outputs": [ 56 | { 57 | "name": "stderr", 58 | "output_type": "stream", 59 | "text": [ 60 | "c:\\users\\themachine\\.conda\\envs\\python36\\lib\\site-packages\\ipykernel_launcher.py:1: DeprecationWarning: database_names is deprecated. Use list_database_names instead.\n", 61 | " \"\"\"Entry point for launching an IPython kernel.\n" 62 | ] 63 | }, 64 | { 65 | "data": { 66 | "text/plain": [ 67 | "['admin', 'config', 'local', 'mpgDataBase']" 68 | ] 69 | }, 70 | "execution_count": 3, 71 | "metadata": {}, 72 | "output_type": "execute_result" 73 | } 74 | ], 75 | "source": [ 76 | "client.database_names()" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": 4, 82 | "metadata": {}, 83 | "outputs": [], 84 | "source": [ 85 | "db = client['mpgDataBase']" 86 | ] 87 | }, 88 | { 89 | "cell_type": "code", 90 | "execution_count": 5, 91 | "metadata": {}, 92 | "outputs": [], 93 | "source": [ 94 | "collectionD = db['mpgTable']" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": 9, 100 | "metadata": {}, 101 | "outputs": [ 102 | { 103 | "data": { 104 | "text/plain": [ 105 | "{'cylinders': 1,\n", 106 | " 'displacement': 2,\n", 107 | " 'horsepower': 3,\n", 108 | " 'weight': 4,\n", 109 | " 'acceleration': 5,\n", 110 | " 'model year': 6,\n", 111 | " 'origin': 1}" 112 | ] 113 | }, 114 | "execution_count": 9, 115 | "metadata": {}, 116 | "output_type": "execute_result" 117 | } 118 | ], 119 | "source": [ 120 | "temp={}\n", 121 | "temp['cylinders']=1\n", 122 | "temp['displacement']=2\n", 123 | "temp['horsepower']=3\n", 124 | "temp['weight']=4\n", 125 | "temp['acceleration']=5\n", 126 | "temp['model year']=6\n", 127 | "temp['origin']=1\n", 128 | "temp" 129 | ] 130 | }, 131 | { 132 | "cell_type": "code", 133 | "execution_count": 10, 134 | "metadata": {}, 135 | "outputs": [], 136 | "source": [ 137 | "pp=collectionD.insert_one(temp)" 138 | ] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "execution_count": 11, 143 | "metadata": {}, 144 | "outputs": [ 145 | { 146 | "data": { 147 | "text/plain": [ 148 | "True" 149 | ] 150 | }, 151 | "execution_count": 11, 152 | "metadata": {}, 153 | "output_type": "execute_result" 154 | } 155 | ], 156 | "source": [ 157 | "pp.acknowledged" 158 | ] 159 | }, 160 | { 161 | "cell_type": "code", 162 | "execution_count": 12, 163 | "metadata": {}, 164 | "outputs": [ 165 | { 166 | "data": { 167 | "text/plain": [ 168 | "ObjectId('5e5cd3680c2fe68649203981')" 169 | ] 170 | }, 171 | "execution_count": 12, 172 | "metadata": {}, 173 | "output_type": "execute_result" 174 | } 175 | ], 176 | "source": [ 177 | "pp.inserted_id" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": 13, 183 | "metadata": {}, 184 | "outputs": [ 185 | { 186 | "data": { 187 | "text/plain": [ 188 | "['mpgTable']" 189 | ] 190 | }, 191 | "execution_count": 13, 192 | "metadata": {}, 193 | "output_type": "execute_result" 194 | } 195 | ], 196 | "source": [ 197 | "db.list_collection_names()" 198 | ] 199 | }, 200 | { 201 | "cell_type": "code", 202 | "execution_count": 15, 203 | "metadata": {}, 204 | "outputs": [ 205 | { 206 | "data": { 207 | "text/plain": [ 208 | "{'_id': ObjectId('5e5cd3680c2fe68649203981'),\n", 209 | " 'cylinders': 1,\n", 210 | " 'displacement': 2,\n", 211 | " 'horsepower': 3,\n", 212 | " 'weight': 4,\n", 213 | " 'acceleration': 5,\n", 214 | " 'model year': 6,\n", 215 | " 'origin': 1}" 216 | ] 217 | }, 218 | "execution_count": 15, 219 | "metadata": {}, 220 | "output_type": "execute_result" 221 | } 222 | ], 223 | "source": [ 224 | "collectionD.find_one()" 225 | ] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": 16, 230 | "metadata": {}, 231 | "outputs": [ 232 | { 233 | "name": "stdout", 234 | "output_type": "stream", 235 | "text": [ 236 | "{'_id': ObjectId('5e5cd3680c2fe68649203981'), 'cylinders': 1, 'displacement': 2, 'horsepower': 3, 'weight': 4, 'acceleration': 5, 'model year': 6, 'origin': 1}\n" 237 | ] 238 | } 239 | ], 240 | "source": [ 241 | "for i in collectionD.find():\n", 242 | " print (i)" 243 | ] 244 | }, 245 | { 246 | "cell_type": "code", 247 | "execution_count": 17, 248 | "metadata": {}, 249 | "outputs": [ 250 | { 251 | "name": "stderr", 252 | "output_type": "stream", 253 | "text": [ 254 | "c:\\users\\themachine\\.conda\\envs\\python36\\lib\\site-packages\\ipykernel_launcher.py:1: DeprecationWarning: count is deprecated. Use Collection.count_documents instead.\n", 255 | " \"\"\"Entry point for launching an IPython kernel.\n" 256 | ] 257 | }, 258 | { 259 | "data": { 260 | "text/plain": [ 261 | "1" 262 | ] 263 | }, 264 | "execution_count": 17, 265 | "metadata": {}, 266 | "output_type": "execute_result" 267 | } 268 | ], 269 | "source": [ 270 | "collectionD.find().count()" 271 | ] 272 | }, 273 | { 274 | "cell_type": "code", 275 | "execution_count": 6, 276 | "metadata": {}, 277 | "outputs": [], 278 | "source": [ 279 | "import pandas as pd" 280 | ] 281 | }, 282 | { 283 | "cell_type": "code", 284 | "execution_count": 7, 285 | "metadata": {}, 286 | "outputs": [], 287 | "source": [ 288 | "data=pd.read_csv('../mpg_data_example.csv')" 289 | ] 290 | }, 291 | { 292 | "cell_type": "code", 293 | "execution_count": 8, 294 | "metadata": {}, 295 | "outputs": [ 296 | { 297 | "name": "stderr", 298 | "output_type": "stream", 299 | "text": [ 300 | "c:\\users\\themachine\\.conda\\envs\\python36\\lib\\site-packages\\ipykernel_launcher.py:2: FutureWarning: \n", 301 | ".ix is deprecated. Please use\n", 302 | ".loc for label based indexing or\n", 303 | ".iloc for positional indexing\n", 304 | "\n", 305 | "See the documentation here:\n", 306 | "http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#ix-indexer-is-deprecated\n", 307 | " \n" 308 | ] 309 | } 310 | ], 311 | "source": [ 312 | "for i in range(10,100):\n", 313 | " tempData=dict(data.ix[i])\n", 314 | " for j in tempData:\n", 315 | " try:\n", 316 | " tempData[j]=float(tempData[j])\n", 317 | " except:\n", 318 | " pass\n", 319 | " collectionD.insert_one(tempData)" 320 | ] 321 | }, 322 | { 323 | "cell_type": "code", 324 | "execution_count": 9, 325 | "metadata": {}, 326 | "outputs": [ 327 | { 328 | "name": "stderr", 329 | "output_type": "stream", 330 | "text": [ 331 | "c:\\users\\themachine\\.conda\\envs\\python36\\lib\\site-packages\\ipykernel_launcher.py:1: DeprecationWarning: count is deprecated. Use Collection.count_documents instead.\n", 332 | " \"\"\"Entry point for launching an IPython kernel.\n" 333 | ] 334 | }, 335 | { 336 | "data": { 337 | "text/plain": [ 338 | "91" 339 | ] 340 | }, 341 | "execution_count": 9, 342 | "metadata": {}, 343 | "output_type": "execute_result" 344 | } 345 | ], 346 | "source": [ 347 | "collectionD.find().count()" 348 | ] 349 | }, 350 | { 351 | "cell_type": "code", 352 | "execution_count": null, 353 | "metadata": {}, 354 | "outputs": [], 355 | "source": [] 356 | } 357 | ], 358 | "metadata": { 359 | "kernelspec": { 360 | "display_name": "Python 3", 361 | "language": "python", 362 | "name": "python3" 363 | }, 364 | "language_info": { 365 | "codemirror_mode": { 366 | "name": "ipython", 367 | "version": 3 368 | }, 369 | "file_extension": ".py", 370 | "mimetype": "text/x-python", 371 | "name": "python", 372 | "nbconvert_exporter": "python", 373 | "pygments_lexer": "ipython3", 374 | "version": "3.6.9" 375 | } 376 | }, 377 | "nbformat": 4, 378 | "nbformat_minor": 2 379 | } 380 | -------------------------------------------------------------------------------- /selenium/Selenium 2.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## Working with Select in Selenium" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 2, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import selenium\n", 17 | "from selenium import webdriver as wb \n", 18 | "from selenium.webdriver.support.ui import Select" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 3, 24 | "metadata": { 25 | "scrolled": true 26 | }, 27 | "outputs": [], 28 | "source": [ 29 | "webD=wb.Chrome('chromedriver.exe')" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": 4, 35 | "metadata": {}, 36 | "outputs": [], 37 | "source": [ 38 | "webD.get('http://localhost:8000/')" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": null, 44 | "metadata": {}, 45 | "outputs": [], 46 | "source": [ 47 | "# someForm=webD.find_element_by_class_name('form1')" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": null, 53 | "metadata": {}, 54 | "outputs": [], 55 | "source": [ 56 | "# someForm.text" 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": 5, 62 | "metadata": {}, 63 | "outputs": [ 64 | { 65 | "data": { 66 | "text/plain": [ 67 | "[,\n", 68 | " ]" 69 | ] 70 | }, 71 | "execution_count": 5, 72 | "metadata": {}, 73 | "output_type": "execute_result" 74 | } 75 | ], 76 | "source": [ 77 | "webD.find_elements_by_name('dropDown')" 78 | ] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "execution_count": 9, 83 | "metadata": {}, 84 | "outputs": [], 85 | "source": [ 86 | "select = Select(webD.find_element_by_name('dropDown'))" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": 16, 92 | "metadata": {}, 93 | "outputs": [ 94 | { 95 | "name": "stdout", 96 | "output_type": "stream", 97 | "text": [ 98 | "Option1\n", 99 | "Option2\n", 100 | "Option3\n", 101 | "Option4\n" 102 | ] 103 | } 104 | ], 105 | "source": [ 106 | "for i in selectN.options:\n", 107 | " print(i.text)" 108 | ] 109 | }, 110 | { 111 | "cell_type": "code", 112 | "execution_count": 15, 113 | "metadata": {}, 114 | "outputs": [], 115 | "source": [ 116 | "selectN=Select(webD.find_elements_by_name('dropDown')[1])" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": 17, 122 | "metadata": {}, 123 | "outputs": [], 124 | "source": [ 125 | "selectN.select_by_value('Option3')" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": null, 131 | "metadata": {}, 132 | "outputs": [], 133 | "source": [] 134 | }, 135 | { 136 | "cell_type": "code", 137 | "execution_count": 13, 138 | "metadata": {}, 139 | "outputs": [], 140 | "source": [ 141 | "select.select_by_value('Option4')" 142 | ] 143 | }, 144 | { 145 | "cell_type": "code", 146 | "execution_count": null, 147 | "metadata": {}, 148 | "outputs": [], 149 | "source": [ 150 | "for i in select.options:\n", 151 | " print(i.text)" 152 | ] 153 | }, 154 | { 155 | "cell_type": "markdown", 156 | "metadata": {}, 157 | "source": [ 158 | "## Extracting complete table from an HTML" 159 | ] 160 | }, 161 | { 162 | "cell_type": "code", 163 | "execution_count": null, 164 | "metadata": {}, 165 | "outputs": [], 166 | "source": [ 167 | "# webD=wb.Chrome('chromedriver.exe')" 168 | ] 169 | }, 170 | { 171 | "cell_type": "code", 172 | "execution_count": null, 173 | "metadata": {}, 174 | "outputs": [], 175 | "source": [ 176 | "# webD.find_element_by_xpath('//*[@id=\"main\"]/div[3]/div')" 177 | ] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": 19, 182 | "metadata": {}, 183 | "outputs": [], 184 | "source": [ 185 | "import pandas as pd" 186 | ] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": 21, 191 | "metadata": { 192 | "scrolled": false 193 | }, 194 | "outputs": [ 195 | { 196 | "data": { 197 | "text/html": [ 198 | "
\n", 199 | "\n", 212 | "\n", 213 | " \n", 214 | " \n", 215 | " \n", 216 | " \n", 217 | " \n", 218 | " \n", 219 | " \n", 220 | " \n", 221 | " \n", 222 | " \n", 223 | " \n", 224 | " \n", 225 | " \n", 226 | " \n", 227 | " \n", 228 | " \n", 229 | " \n", 230 | " \n", 231 | " \n", 232 | " \n", 233 | " \n", 234 | " \n", 235 | " \n", 236 | " \n", 237 | " \n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | " \n", 243 | " \n", 244 | " \n", 245 | " \n", 246 | " \n", 247 | " \n", 248 | " \n", 249 | " \n", 250 | " \n", 251 | " \n", 252 | " \n", 253 | " \n", 254 | " \n", 255 | " \n", 256 | " \n", 257 | " \n", 258 | " \n", 259 | " \n", 260 | " \n", 261 | " \n", 262 | " \n", 263 | " \n", 264 | " \n", 265 | " \n", 266 | " \n", 267 | " \n", 268 | " \n", 269 | " \n", 270 | " \n", 271 | " \n", 272 | " \n", 273 | " \n", 274 | " \n", 275 | " \n", 276 | " \n", 277 | "
MonthSavings
0January$100
1February$110
2March$120
3April$130
4May$140
5June$130
6July$150
7August$120
8September$160
9October$130
10November$230
\n", 278 | "
" 279 | ], 280 | "text/plain": [ 281 | " Month Savings\n", 282 | "0 January $100\n", 283 | "1 February $110\n", 284 | "2 March $120\n", 285 | "3 April $130\n", 286 | "4 May $140\n", 287 | "5 June $130\n", 288 | "6 July $150\n", 289 | "7 August $120\n", 290 | "8 September $160\n", 291 | "9 October $130\n", 292 | "10 November $230" 293 | ] 294 | }, 295 | "execution_count": 21, 296 | "metadata": {}, 297 | "output_type": "execute_result" 298 | } 299 | ], 300 | "source": [ 301 | "pd.read_html('http://localhost:8000/')[0]" 302 | ] 303 | }, 304 | { 305 | "cell_type": "markdown", 306 | "metadata": {}, 307 | "source": [ 308 | "## Scrolling in Selenium" 309 | ] 310 | }, 311 | { 312 | "cell_type": "code", 313 | "execution_count": 23, 314 | "metadata": {}, 315 | "outputs": [], 316 | "source": [ 317 | "webD.execute_script(\"window.scrollTo(0, 400)\") #using javascript way" 318 | ] 319 | }, 320 | { 321 | "cell_type": "code", 322 | "execution_count": 24, 323 | "metadata": {}, 324 | "outputs": [], 325 | "source": [ 326 | "webD.execute_script(\"window.scrollTo(0, document.body.scrollHeight)\")" 327 | ] 328 | }, 329 | { 330 | "cell_type": "markdown", 331 | "metadata": {}, 332 | "source": [ 333 | "## What about infinte scrolling" 334 | ] 335 | }, 336 | { 337 | "cell_type": "markdown", 338 | "metadata": {}, 339 | "source": [ 340 | "while loop :\n", 341 | "\n", 342 | "webD.execute_script(\"window.scrollTo(500, 800)\") " 343 | ] 344 | }, 345 | { 346 | "cell_type": "code", 347 | "execution_count": null, 348 | "metadata": {}, 349 | "outputs": [], 350 | "source": [] 351 | } 352 | ], 353 | "metadata": { 354 | "kernelspec": { 355 | "display_name": "Python 3", 356 | "language": "python", 357 | "name": "python3" 358 | }, 359 | "language_info": { 360 | "codemirror_mode": { 361 | "name": "ipython", 362 | "version": 3 363 | }, 364 | "file_extension": ".py", 365 | "mimetype": "text/x-python", 366 | "name": "python", 367 | "nbconvert_exporter": "python", 368 | "pygments_lexer": "ipython3", 369 | "version": "3.6.9" 370 | } 371 | }, 372 | "nbformat": 4, 373 | "nbformat_minor": 2 374 | } 375 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/Selenium 2-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## Working with Select in Selenium" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 2, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import selenium\n", 17 | "from selenium import webdriver as wb \n", 18 | "from selenium.webdriver.support.ui import Select" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 3, 24 | "metadata": { 25 | "scrolled": true 26 | }, 27 | "outputs": [], 28 | "source": [ 29 | "webD=wb.Chrome('chromedriver.exe')" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": 4, 35 | "metadata": {}, 36 | "outputs": [], 37 | "source": [ 38 | "webD.get('http://localhost:8000/')" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": null, 44 | "metadata": {}, 45 | "outputs": [], 46 | "source": [ 47 | "# someForm=webD.find_element_by_class_name('form1')" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": null, 53 | "metadata": {}, 54 | "outputs": [], 55 | "source": [ 56 | "# someForm.text" 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": 5, 62 | "metadata": {}, 63 | "outputs": [ 64 | { 65 | "data": { 66 | "text/plain": [ 67 | "[,\n", 68 | " ]" 69 | ] 70 | }, 71 | "execution_count": 5, 72 | "metadata": {}, 73 | "output_type": "execute_result" 74 | } 75 | ], 76 | "source": [ 77 | "webD.find_elements_by_name('dropDown')" 78 | ] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "execution_count": 9, 83 | "metadata": {}, 84 | "outputs": [], 85 | "source": [ 86 | "select = Select(webD.find_element_by_name('dropDown'))" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": 16, 92 | "metadata": {}, 93 | "outputs": [ 94 | { 95 | "name": "stdout", 96 | "output_type": "stream", 97 | "text": [ 98 | "Option1\n", 99 | "Option2\n", 100 | "Option3\n", 101 | "Option4\n" 102 | ] 103 | } 104 | ], 105 | "source": [ 106 | "for i in selectN.options:\n", 107 | " print(i.text)" 108 | ] 109 | }, 110 | { 111 | "cell_type": "code", 112 | "execution_count": 15, 113 | "metadata": {}, 114 | "outputs": [], 115 | "source": [ 116 | "selectN=Select(webD.find_elements_by_name('dropDown')[1])" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": 17, 122 | "metadata": {}, 123 | "outputs": [], 124 | "source": [ 125 | "selectN.select_by_value('Option3')" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": null, 131 | "metadata": {}, 132 | "outputs": [], 133 | "source": [] 134 | }, 135 | { 136 | "cell_type": "code", 137 | "execution_count": 13, 138 | "metadata": {}, 139 | "outputs": [], 140 | "source": [ 141 | "select.select_by_value('Option4')" 142 | ] 143 | }, 144 | { 145 | "cell_type": "code", 146 | "execution_count": null, 147 | "metadata": {}, 148 | "outputs": [], 149 | "source": [ 150 | "for i in select.options:\n", 151 | " print(i.text)" 152 | ] 153 | }, 154 | { 155 | "cell_type": "markdown", 156 | "metadata": {}, 157 | "source": [ 158 | "## Extracting complete table from an HTML" 159 | ] 160 | }, 161 | { 162 | "cell_type": "code", 163 | "execution_count": null, 164 | "metadata": {}, 165 | "outputs": [], 166 | "source": [ 167 | "# webD=wb.Chrome('chromedriver.exe')" 168 | ] 169 | }, 170 | { 171 | "cell_type": "code", 172 | "execution_count": null, 173 | "metadata": {}, 174 | "outputs": [], 175 | "source": [ 176 | "# webD.find_element_by_xpath('//*[@id=\"main\"]/div[3]/div')" 177 | ] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": 19, 182 | "metadata": {}, 183 | "outputs": [], 184 | "source": [ 185 | "import pandas as pd" 186 | ] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": 21, 191 | "metadata": { 192 | "scrolled": false 193 | }, 194 | "outputs": [ 195 | { 196 | "data": { 197 | "text/html": [ 198 | "
\n", 199 | "\n", 212 | "\n", 213 | " \n", 214 | " \n", 215 | " \n", 216 | " \n", 217 | " \n", 218 | " \n", 219 | " \n", 220 | " \n", 221 | " \n", 222 | " \n", 223 | " \n", 224 | " \n", 225 | " \n", 226 | " \n", 227 | " \n", 228 | " \n", 229 | " \n", 230 | " \n", 231 | " \n", 232 | " \n", 233 | " \n", 234 | " \n", 235 | " \n", 236 | " \n", 237 | " \n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | " \n", 243 | " \n", 244 | " \n", 245 | " \n", 246 | " \n", 247 | " \n", 248 | " \n", 249 | " \n", 250 | " \n", 251 | " \n", 252 | " \n", 253 | " \n", 254 | " \n", 255 | " \n", 256 | " \n", 257 | " \n", 258 | " \n", 259 | " \n", 260 | " \n", 261 | " \n", 262 | " \n", 263 | " \n", 264 | " \n", 265 | " \n", 266 | " \n", 267 | " \n", 268 | " \n", 269 | " \n", 270 | " \n", 271 | " \n", 272 | " \n", 273 | " \n", 274 | " \n", 275 | " \n", 276 | " \n", 277 | "
MonthSavings
0January$100
1February$110
2March$120
3April$130
4May$140
5June$130
6July$150
7August$120
8September$160
9October$130
10November$230
\n", 278 | "
" 279 | ], 280 | "text/plain": [ 281 | " Month Savings\n", 282 | "0 January $100\n", 283 | "1 February $110\n", 284 | "2 March $120\n", 285 | "3 April $130\n", 286 | "4 May $140\n", 287 | "5 June $130\n", 288 | "6 July $150\n", 289 | "7 August $120\n", 290 | "8 September $160\n", 291 | "9 October $130\n", 292 | "10 November $230" 293 | ] 294 | }, 295 | "execution_count": 21, 296 | "metadata": {}, 297 | "output_type": "execute_result" 298 | } 299 | ], 300 | "source": [ 301 | "pd.read_html('http://localhost:8000/')[0]" 302 | ] 303 | }, 304 | { 305 | "cell_type": "markdown", 306 | "metadata": {}, 307 | "source": [ 308 | "## Scrolling in Selenium" 309 | ] 310 | }, 311 | { 312 | "cell_type": "code", 313 | "execution_count": 23, 314 | "metadata": {}, 315 | "outputs": [], 316 | "source": [ 317 | "webD.execute_script(\"window.scrollTo(0, 400)\") #using javascript way" 318 | ] 319 | }, 320 | { 321 | "cell_type": "code", 322 | "execution_count": 24, 323 | "metadata": {}, 324 | "outputs": [], 325 | "source": [ 326 | "webD.execute_script(\"window.scrollTo(0, document.body.scrollHeight)\")" 327 | ] 328 | }, 329 | { 330 | "cell_type": "markdown", 331 | "metadata": {}, 332 | "source": [ 333 | "## What about infinte scrolling" 334 | ] 335 | }, 336 | { 337 | "cell_type": "markdown", 338 | "metadata": {}, 339 | "source": [ 340 | "while loop :\n", 341 | "\n", 342 | "webD.execute_script(\"window.scrollTo(500, 800)\") " 343 | ] 344 | }, 345 | { 346 | "cell_type": "code", 347 | "execution_count": null, 348 | "metadata": {}, 349 | "outputs": [], 350 | "source": [] 351 | } 352 | ], 353 | "metadata": { 354 | "kernelspec": { 355 | "display_name": "Python 3", 356 | "language": "python", 357 | "name": "python3" 358 | }, 359 | "language_info": { 360 | "codemirror_mode": { 361 | "name": "ipython", 362 | "version": 3 363 | }, 364 | "file_extension": ".py", 365 | "mimetype": "text/x-python", 366 | "name": "python", 367 | "nbconvert_exporter": "python", 368 | "pygments_lexer": "ipython3", 369 | "version": "3.6.9" 370 | } 371 | }, 372 | "nbformat": 4, 373 | "nbformat_minor": 2 374 | } 375 | -------------------------------------------------------------------------------- /instagramAutomation/insta Uplaod images.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from uiautomator import device as d\n", 10 | "from uiautomator import Device\n", 11 | "from time import sleep\n", 12 | "import os" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "metadata": {}, 19 | "outputs": [], 20 | "source": [ 21 | "d.info" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": null, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "d.infod = Device('375637504c583398')\n", 31 | "\n", 32 | "d.info" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 4, 38 | "metadata": {}, 39 | "outputs": [], 40 | "source": [ 41 | "# d.dump('someHier.xml')" 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "execution_count": 5, 47 | "metadata": {}, 48 | "outputs": [ 49 | { 50 | "data": { 51 | "text/plain": [ 52 | "True" 53 | ] 54 | }, 55 | "execution_count": 5, 56 | "metadata": {}, 57 | "output_type": "execute_result" 58 | } 59 | ], 60 | "source": [ 61 | "d.press.home()\n", 62 | "sx, sy, ex, ey= 100 ,150,100,450\n", 63 | "d.swipe(sx, sy, ex, ey, steps=5)" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 6, 69 | "metadata": {}, 70 | "outputs": [ 71 | { 72 | "data": { 73 | "text/plain": [ 74 | "True" 75 | ] 76 | }, 77 | "execution_count": 6, 78 | "metadata": {}, 79 | "output_type": "execute_result" 80 | } 81 | ], 82 | "source": [ 83 | "instaVal=d(text='Gallery', className='android.widget.TextView')\n", 84 | "instaVal.click()" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": 7, 90 | "metadata": {}, 91 | "outputs": [ 92 | { 93 | "data": { 94 | "text/plain": [ 95 | "True" 96 | ] 97 | }, 98 | "execution_count": 7, 99 | "metadata": {}, 100 | "output_type": "execute_result" 101 | } 102 | ], 103 | "source": [ 104 | "sx, sy, ex, ey= 560,800,560 ,150\n", 105 | "d.swipe(sx, sy, ex, ey, steps=10)" 106 | ] 107 | }, 108 | { 109 | "cell_type": "code", 110 | "execution_count": 8, 111 | "metadata": {}, 112 | "outputs": [ 113 | { 114 | "data": { 115 | "text/plain": [ 116 | "True" 117 | ] 118 | }, 119 | "execution_count": 8, 120 | "metadata": {}, 121 | "output_type": "execute_result" 122 | } 123 | ], 124 | "source": [ 125 | "pp=d(className='android.widget.TextView',text='Downloads')#,index=\"2\")\n", 126 | "pp.click()" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 9, 132 | "metadata": {}, 133 | "outputs": [], 134 | "source": [ 135 | "nextInd=str(3)" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": 10, 141 | "metadata": {}, 142 | "outputs": [ 143 | { 144 | "data": { 145 | "text/plain": [ 146 | "True" 147 | ] 148 | }, 149 | "execution_count": 10, 150 | "metadata": {}, 151 | "output_type": "execute_result" 152 | } 153 | ], 154 | "source": [ 155 | "pp=d(className='android.widget.FrameLayout',resourceId=\"com.sec.android.gallery3d:id/recycler_view_item\",index=nextInd)#,index=\"2\")\n", 156 | "pp.click()" 157 | ] 158 | }, 159 | { 160 | "cell_type": "code", 161 | "execution_count": 11, 162 | "metadata": {}, 163 | "outputs": [ 164 | { 165 | "data": { 166 | "text/plain": [ 167 | "True" 168 | ] 169 | }, 170 | "execution_count": 11, 171 | "metadata": {}, 172 | "output_type": "execute_result" 173 | } 174 | ], 175 | "source": [ 176 | "# d.screenshot('saveIMage.png')\n", 177 | "pp=d(className='android.widget.RelativeLayout',resourceId='com.sec.android.gallery3d:id/btn_share')#,index=\"2\")\n", 178 | "pp.click()" 179 | ] 180 | }, 181 | { 182 | "cell_type": "code", 183 | "execution_count": 12, 184 | "metadata": {}, 185 | "outputs": [ 186 | { 187 | "data": { 188 | "text/plain": [ 189 | "True" 190 | ] 191 | }, 192 | "execution_count": 12, 193 | "metadata": {}, 194 | "output_type": "execute_result" 195 | } 196 | ], 197 | "source": [ 198 | "pp=d(className='android.widget.TextView',text='Feed')#,index=\"2\")\n", 199 | "pp.click()" 200 | ] 201 | }, 202 | { 203 | "cell_type": "code", 204 | "execution_count": 13, 205 | "metadata": {}, 206 | "outputs": [ 207 | { 208 | "data": { 209 | "text/plain": [ 210 | "True" 211 | ] 212 | }, 213 | "execution_count": 13, 214 | "metadata": {}, 215 | "output_type": "execute_result" 216 | } 217 | ], 218 | "source": [ 219 | "pp=d(className='android.widget.ImageView',resourceId='com.instagram.android:id/croptype_toggle_button')#,index=\"2\")\n", 220 | "pp.click()" 221 | ] 222 | }, 223 | { 224 | "cell_type": "code", 225 | "execution_count": 14, 226 | "metadata": {}, 227 | "outputs": [ 228 | { 229 | "data": { 230 | "text/plain": [ 231 | "True" 232 | ] 233 | }, 234 | "execution_count": 14, 235 | "metadata": {}, 236 | "output_type": "execute_result" 237 | } 238 | ], 239 | "source": [ 240 | "pp=d(className='android.widget.ImageView',resourceId='com.instagram.android:id/save')#,index=\"2\")\n", 241 | "pp.click()" 242 | ] 243 | }, 244 | { 245 | "cell_type": "code", 246 | "execution_count": 15, 247 | "metadata": {}, 248 | "outputs": [ 249 | { 250 | "data": { 251 | "text/plain": [ 252 | "True" 253 | ] 254 | }, 255 | "execution_count": 15, 256 | "metadata": {}, 257 | "output_type": "execute_result" 258 | } 259 | ], 260 | "source": [ 261 | "pp=d(className='android.widget.TextView',text='Next')#,index=\"2\")\n", 262 | "pp.click()" 263 | ] 264 | }, 265 | { 266 | "cell_type": "code", 267 | "execution_count": 16, 268 | "metadata": {}, 269 | "outputs": [ 270 | { 271 | "data": { 272 | "text/plain": [ 273 | "True" 274 | ] 275 | }, 276 | "execution_count": 16, 277 | "metadata": {}, 278 | "output_type": "execute_result" 279 | } 280 | ], 281 | "source": [ 282 | "pp=d(className='android.widget.EditText')#,index=\"2\")\n", 283 | "pp.click()" 284 | ] 285 | }, 286 | { 287 | "cell_type": "code", 288 | "execution_count": 17, 289 | "metadata": {}, 290 | "outputs": [], 291 | "source": [ 292 | "textData='#Jaguar #Jaguars #jaguarftype #jaguarEtype #jaguarcars #jaguarfpace #jaguarxf #JaguarXJ #Jaguariuna #jaguarrussia #JaguarXE #jaguarusa #jaguarftypes #jaguarclub #jaguarclassic #jaguarftyper #jaguarxk #JaguarXJS #jaguarlife #jaguarlandrover #jaguarexperience #jaguarftypesvr #jaguarnation #jaguarpalmbeach #Jaguares #jaguarxkr #jaguarfans #jaguarsvr #jaguarundi #jaguarstyle'" 293 | ] 294 | }, 295 | { 296 | "cell_type": "code", 297 | "execution_count": 18, 298 | "metadata": {}, 299 | "outputs": [ 300 | { 301 | "data": { 302 | "text/plain": [ 303 | "True" 304 | ] 305 | }, 306 | "execution_count": 18, 307 | "metadata": {}, 308 | "output_type": "execute_result" 309 | } 310 | ], 311 | "source": [ 312 | "pp.set_text('Jaguar from the Mysore Zoo. '+textData)" 313 | ] 314 | }, 315 | { 316 | "cell_type": "code", 317 | "execution_count": null, 318 | "metadata": {}, 319 | "outputs": [], 320 | "source": [ 321 | "pp=d(className='android.widget.TextView',text='Share')#,index=\"2\")\n", 322 | "pp.click()\n", 323 | "\n", 324 | "for i in range(2):\n", 325 | " d.press.back()" 326 | ] 327 | }, 328 | { 329 | "cell_type": "code", 330 | "execution_count": null, 331 | "metadata": { 332 | "scrolled": true 333 | }, 334 | "outputs": [], 335 | "source": [] 336 | }, 337 | { 338 | "cell_type": "code", 339 | "execution_count": null, 340 | "metadata": {}, 341 | "outputs": [], 342 | "source": [] 343 | }, 344 | { 345 | "cell_type": "code", 346 | "execution_count": null, 347 | "metadata": {}, 348 | "outputs": [], 349 | "source": [] 350 | }, 351 | { 352 | "cell_type": "code", 353 | "execution_count": null, 354 | "metadata": {}, 355 | "outputs": [], 356 | "source": [] 357 | }, 358 | { 359 | "cell_type": "code", 360 | "execution_count": null, 361 | "metadata": {}, 362 | "outputs": [], 363 | "source": [] 364 | }, 365 | { 366 | "cell_type": "code", 367 | "execution_count": null, 368 | "metadata": {}, 369 | "outputs": [], 370 | "source": [] 371 | }, 372 | { 373 | "cell_type": "code", 374 | "execution_count": null, 375 | "metadata": {}, 376 | "outputs": [], 377 | "source": [] 378 | }, 379 | { 380 | "cell_type": "code", 381 | "execution_count": null, 382 | "metadata": {}, 383 | "outputs": [], 384 | "source": [] 385 | } 386 | ], 387 | "metadata": { 388 | "kernelspec": { 389 | "display_name": "Python 3", 390 | "language": "python", 391 | "name": "python3" 392 | }, 393 | "language_info": { 394 | "codemirror_mode": { 395 | "name": "ipython", 396 | "version": 3 397 | }, 398 | "file_extension": ".py", 399 | "mimetype": "text/x-python", 400 | "name": "python", 401 | "nbconvert_exporter": "python", 402 | "pygments_lexer": "ipython3", 403 | "version": "3.6.9" 404 | } 405 | }, 406 | "nbformat": 4, 407 | "nbformat_minor": 2 408 | } 409 | -------------------------------------------------------------------------------- /instagramAutomation/.ipynb_checkpoints/insta Uplaod images-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from uiautomator import device as d\n", 10 | "from uiautomator import Device\n", 11 | "from time import sleep\n", 12 | "import os" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "metadata": {}, 19 | "outputs": [], 20 | "source": [ 21 | "d.info" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": null, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "d.infod = Device('375637504c583398')\n", 31 | "\n", 32 | "d.info" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 4, 38 | "metadata": {}, 39 | "outputs": [], 40 | "source": [ 41 | "# d.dump('someHier.xml')" 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "execution_count": 5, 47 | "metadata": {}, 48 | "outputs": [ 49 | { 50 | "data": { 51 | "text/plain": [ 52 | "True" 53 | ] 54 | }, 55 | "execution_count": 5, 56 | "metadata": {}, 57 | "output_type": "execute_result" 58 | } 59 | ], 60 | "source": [ 61 | "d.press.home()\n", 62 | "sx, sy, ex, ey= 100 ,150,100,450\n", 63 | "d.swipe(sx, sy, ex, ey, steps=5)" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 6, 69 | "metadata": {}, 70 | "outputs": [ 71 | { 72 | "data": { 73 | "text/plain": [ 74 | "True" 75 | ] 76 | }, 77 | "execution_count": 6, 78 | "metadata": {}, 79 | "output_type": "execute_result" 80 | } 81 | ], 82 | "source": [ 83 | "instaVal=d(text='Gallery', className='android.widget.TextView')\n", 84 | "instaVal.click()" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": 7, 90 | "metadata": {}, 91 | "outputs": [ 92 | { 93 | "data": { 94 | "text/plain": [ 95 | "True" 96 | ] 97 | }, 98 | "execution_count": 7, 99 | "metadata": {}, 100 | "output_type": "execute_result" 101 | } 102 | ], 103 | "source": [ 104 | "sx, sy, ex, ey= 560,800,560 ,150\n", 105 | "d.swipe(sx, sy, ex, ey, steps=10)" 106 | ] 107 | }, 108 | { 109 | "cell_type": "code", 110 | "execution_count": 8, 111 | "metadata": {}, 112 | "outputs": [ 113 | { 114 | "data": { 115 | "text/plain": [ 116 | "True" 117 | ] 118 | }, 119 | "execution_count": 8, 120 | "metadata": {}, 121 | "output_type": "execute_result" 122 | } 123 | ], 124 | "source": [ 125 | "pp=d(className='android.widget.TextView',text='Downloads')#,index=\"2\")\n", 126 | "pp.click()" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 9, 132 | "metadata": {}, 133 | "outputs": [], 134 | "source": [ 135 | "nextInd=str(3)" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": 10, 141 | "metadata": {}, 142 | "outputs": [ 143 | { 144 | "data": { 145 | "text/plain": [ 146 | "True" 147 | ] 148 | }, 149 | "execution_count": 10, 150 | "metadata": {}, 151 | "output_type": "execute_result" 152 | } 153 | ], 154 | "source": [ 155 | "pp=d(className='android.widget.FrameLayout',resourceId=\"com.sec.android.gallery3d:id/recycler_view_item\",index=nextInd)#,index=\"2\")\n", 156 | "pp.click()" 157 | ] 158 | }, 159 | { 160 | "cell_type": "code", 161 | "execution_count": 11, 162 | "metadata": {}, 163 | "outputs": [ 164 | { 165 | "data": { 166 | "text/plain": [ 167 | "True" 168 | ] 169 | }, 170 | "execution_count": 11, 171 | "metadata": {}, 172 | "output_type": "execute_result" 173 | } 174 | ], 175 | "source": [ 176 | "# d.screenshot('saveIMage.png')\n", 177 | "pp=d(className='android.widget.RelativeLayout',resourceId='com.sec.android.gallery3d:id/btn_share')#,index=\"2\")\n", 178 | "pp.click()" 179 | ] 180 | }, 181 | { 182 | "cell_type": "code", 183 | "execution_count": 12, 184 | "metadata": {}, 185 | "outputs": [ 186 | { 187 | "data": { 188 | "text/plain": [ 189 | "True" 190 | ] 191 | }, 192 | "execution_count": 12, 193 | "metadata": {}, 194 | "output_type": "execute_result" 195 | } 196 | ], 197 | "source": [ 198 | "pp=d(className='android.widget.TextView',text='Feed')#,index=\"2\")\n", 199 | "pp.click()" 200 | ] 201 | }, 202 | { 203 | "cell_type": "code", 204 | "execution_count": 13, 205 | "metadata": {}, 206 | "outputs": [ 207 | { 208 | "data": { 209 | "text/plain": [ 210 | "True" 211 | ] 212 | }, 213 | "execution_count": 13, 214 | "metadata": {}, 215 | "output_type": "execute_result" 216 | } 217 | ], 218 | "source": [ 219 | "pp=d(className='android.widget.ImageView',resourceId='com.instagram.android:id/croptype_toggle_button')#,index=\"2\")\n", 220 | "pp.click()" 221 | ] 222 | }, 223 | { 224 | "cell_type": "code", 225 | "execution_count": 14, 226 | "metadata": {}, 227 | "outputs": [ 228 | { 229 | "data": { 230 | "text/plain": [ 231 | "True" 232 | ] 233 | }, 234 | "execution_count": 14, 235 | "metadata": {}, 236 | "output_type": "execute_result" 237 | } 238 | ], 239 | "source": [ 240 | "pp=d(className='android.widget.ImageView',resourceId='com.instagram.android:id/save')#,index=\"2\")\n", 241 | "pp.click()" 242 | ] 243 | }, 244 | { 245 | "cell_type": "code", 246 | "execution_count": 15, 247 | "metadata": {}, 248 | "outputs": [ 249 | { 250 | "data": { 251 | "text/plain": [ 252 | "True" 253 | ] 254 | }, 255 | "execution_count": 15, 256 | "metadata": {}, 257 | "output_type": "execute_result" 258 | } 259 | ], 260 | "source": [ 261 | "pp=d(className='android.widget.TextView',text='Next')#,index=\"2\")\n", 262 | "pp.click()" 263 | ] 264 | }, 265 | { 266 | "cell_type": "code", 267 | "execution_count": 16, 268 | "metadata": {}, 269 | "outputs": [ 270 | { 271 | "data": { 272 | "text/plain": [ 273 | "True" 274 | ] 275 | }, 276 | "execution_count": 16, 277 | "metadata": {}, 278 | "output_type": "execute_result" 279 | } 280 | ], 281 | "source": [ 282 | "pp=d(className='android.widget.EditText')#,index=\"2\")\n", 283 | "pp.click()" 284 | ] 285 | }, 286 | { 287 | "cell_type": "code", 288 | "execution_count": 17, 289 | "metadata": {}, 290 | "outputs": [], 291 | "source": [ 292 | "textData='#Jaguar #Jaguars #jaguarftype #jaguarEtype #jaguarcars #jaguarfpace #jaguarxf #JaguarXJ #Jaguariuna #jaguarrussia #JaguarXE #jaguarusa #jaguarftypes #jaguarclub #jaguarclassic #jaguarftyper #jaguarxk #JaguarXJS #jaguarlife #jaguarlandrover #jaguarexperience #jaguarftypesvr #jaguarnation #jaguarpalmbeach #Jaguares #jaguarxkr #jaguarfans #jaguarsvr #jaguarundi #jaguarstyle'" 293 | ] 294 | }, 295 | { 296 | "cell_type": "code", 297 | "execution_count": 18, 298 | "metadata": {}, 299 | "outputs": [ 300 | { 301 | "data": { 302 | "text/plain": [ 303 | "True" 304 | ] 305 | }, 306 | "execution_count": 18, 307 | "metadata": {}, 308 | "output_type": "execute_result" 309 | } 310 | ], 311 | "source": [ 312 | "pp.set_text('Jaguar from the Mysore Zoo. '+textData)" 313 | ] 314 | }, 315 | { 316 | "cell_type": "code", 317 | "execution_count": null, 318 | "metadata": {}, 319 | "outputs": [], 320 | "source": [ 321 | "pp=d(className='android.widget.TextView',text='Share')#,index=\"2\")\n", 322 | "pp.click()\n", 323 | "\n", 324 | "for i in range(2):\n", 325 | " d.press.back()" 326 | ] 327 | }, 328 | { 329 | "cell_type": "code", 330 | "execution_count": null, 331 | "metadata": { 332 | "scrolled": true 333 | }, 334 | "outputs": [], 335 | "source": [] 336 | }, 337 | { 338 | "cell_type": "code", 339 | "execution_count": null, 340 | "metadata": {}, 341 | "outputs": [], 342 | "source": [] 343 | }, 344 | { 345 | "cell_type": "code", 346 | "execution_count": null, 347 | "metadata": {}, 348 | "outputs": [], 349 | "source": [] 350 | }, 351 | { 352 | "cell_type": "code", 353 | "execution_count": null, 354 | "metadata": {}, 355 | "outputs": [], 356 | "source": [] 357 | }, 358 | { 359 | "cell_type": "code", 360 | "execution_count": null, 361 | "metadata": {}, 362 | "outputs": [], 363 | "source": [] 364 | }, 365 | { 366 | "cell_type": "code", 367 | "execution_count": null, 368 | "metadata": {}, 369 | "outputs": [], 370 | "source": [] 371 | }, 372 | { 373 | "cell_type": "code", 374 | "execution_count": null, 375 | "metadata": {}, 376 | "outputs": [], 377 | "source": [] 378 | }, 379 | { 380 | "cell_type": "code", 381 | "execution_count": null, 382 | "metadata": {}, 383 | "outputs": [], 384 | "source": [] 385 | } 386 | ], 387 | "metadata": { 388 | "kernelspec": { 389 | "display_name": "Python 3", 390 | "language": "python", 391 | "name": "python3" 392 | }, 393 | "language_info": { 394 | "codemirror_mode": { 395 | "name": "ipython", 396 | "version": 3 397 | }, 398 | "file_extension": ".py", 399 | "mimetype": "text/x-python", 400 | "name": "python", 401 | "nbconvert_exporter": "python", 402 | "pygments_lexer": "ipython3", 403 | "version": "3.6.9" 404 | } 405 | }, 406 | "nbformat": 4, 407 | "nbformat_minor": 2 408 | } 409 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/Exceptional Handling-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Errors" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 2, 13 | "metadata": {}, 14 | "outputs": [ 15 | { 16 | "ename": "IndentationError", 17 | "evalue": "expected an indented block (, line 2)", 18 | "output_type": "error", 19 | "traceback": [ 20 | "\u001b[1;36m File \u001b[1;32m\"\"\u001b[1;36m, line \u001b[1;32m2\u001b[0m\n\u001b[1;33m print (i)\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m expected an indented block\n" 21 | ] 22 | } 23 | ], 24 | "source": [ 25 | "for i in range(10):\n", 26 | "print (i) " 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 3, 32 | "metadata": {}, 33 | "outputs": [ 34 | { 35 | "ename": "ZeroDivisionError", 36 | "evalue": "division by zero", 37 | "output_type": "error", 38 | "traceback": [ 39 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 40 | "\u001b[1;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", 41 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;36m1\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 42 | "\u001b[1;31mZeroDivisionError\u001b[0m: division by zero" 43 | ] 44 | } 45 | ], 46 | "source": [ 47 | "1/0" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": null, 53 | "metadata": {}, 54 | "outputs": [], 55 | "source": [ 56 | "4+ spam*3" 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": null, 62 | "metadata": {}, 63 | "outputs": [], 64 | "source": [ 65 | "'hello'+ 2" 66 | ] 67 | }, 68 | { 69 | "cell_type": "markdown", 70 | "metadata": {}, 71 | "source": [ 72 | "## try and except" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": null, 78 | "metadata": {}, 79 | "outputs": [], 80 | "source": [ 81 | "def sumofValues(x,y):\n", 82 | " return x+y" 83 | ] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "execution_count": null, 88 | "metadata": {}, 89 | "outputs": [], 90 | "source": [ 91 | "sumofValues(1,2)" 92 | ] 93 | }, 94 | { 95 | "cell_type": "code", 96 | "execution_count": null, 97 | "metadata": {}, 98 | "outputs": [], 99 | "source": [ 100 | "sumofValues('1',1)" 101 | ] 102 | }, 103 | { 104 | "cell_type": "code", 105 | "execution_count": null, 106 | "metadata": {}, 107 | "outputs": [], 108 | "source": [ 109 | "def sumofValues(x,y):\n", 110 | " try:\n", 111 | " return x+y\n", 112 | " except:\n", 113 | " return ('None')" 114 | ] 115 | }, 116 | { 117 | "cell_type": "code", 118 | "execution_count": null, 119 | "metadata": {}, 120 | "outputs": [], 121 | "source": [ 122 | "sumofValues('1',1)" 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": null, 128 | "metadata": {}, 129 | "outputs": [], 130 | "source": [ 131 | "def sumofValues(x,y):\n", 132 | " try:\n", 133 | " return x+y\n", 134 | " except TypeError:\n", 135 | " return ('Please provide integers')" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": null, 141 | "metadata": {}, 142 | "outputs": [], 143 | "source": [ 144 | "sumofValues('1',1)" 145 | ] 146 | }, 147 | { 148 | "cell_type": "code", 149 | "execution_count": null, 150 | "metadata": {}, 151 | "outputs": [], 152 | "source": [ 153 | "def divofValues(x,y):\n", 154 | " try:\n", 155 | " return x/y\n", 156 | " except TypeError:\n", 157 | " return ('Please provide integers')" 158 | ] 159 | }, 160 | { 161 | "cell_type": "code", 162 | "execution_count": null, 163 | "metadata": {}, 164 | "outputs": [], 165 | "source": [ 166 | "divofValues(1,1)" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": null, 172 | "metadata": {}, 173 | "outputs": [], 174 | "source": [ 175 | "divofValues(1,'1')" 176 | ] 177 | }, 178 | { 179 | "cell_type": "code", 180 | "execution_count": null, 181 | "metadata": {}, 182 | "outputs": [], 183 | "source": [ 184 | "divofValues(1,0)" 185 | ] 186 | }, 187 | { 188 | "cell_type": "code", 189 | "execution_count": null, 190 | "metadata": {}, 191 | "outputs": [], 192 | "source": [ 193 | "def divofValues(x,y):\n", 194 | " try:\n", 195 | " return x/y\n", 196 | " except TypeError:\n", 197 | " return ('Please provide integers')\n", 198 | " except ZeroDivisionError:\n", 199 | " return ('Denominator is 0')" 200 | ] 201 | }, 202 | { 203 | "cell_type": "code", 204 | "execution_count": null, 205 | "metadata": {}, 206 | "outputs": [], 207 | "source": [ 208 | "divofValues(1,0)" 209 | ] 210 | }, 211 | { 212 | "cell_type": "code", 213 | "execution_count": null, 214 | "metadata": {}, 215 | "outputs": [], 216 | "source": [ 217 | "divofValues(1,l)" 218 | ] 219 | }, 220 | { 221 | "cell_type": "markdown", 222 | "metadata": {}, 223 | "source": [ 224 | "## Multiple excesptions" 225 | ] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": null, 230 | "metadata": {}, 231 | "outputs": [], 232 | "source": [ 233 | "def divofValues(x,y):\n", 234 | " try:\n", 235 | " return x/y\n", 236 | " except TypeError:\n", 237 | " return ('Please provide integers')\n", 238 | " except ZeroDivisionError:\n", 239 | " return ('Denominator is 0')" 240 | ] 241 | }, 242 | { 243 | "cell_type": "markdown", 244 | "metadata": {}, 245 | "source": [ 246 | "## Getting details from the Exceptions" 247 | ] 248 | }, 249 | { 250 | "cell_type": "code", 251 | "execution_count": null, 252 | "metadata": {}, 253 | "outputs": [], 254 | "source": [ 255 | "def divofValues(x,y):\n", 256 | " try:\n", 257 | " return x/y\n", 258 | " except TypeError:\n", 259 | " return ('Please provide integers')\n", 260 | " except ZeroDivisionError as e:\n", 261 | " return ('Denominator is 0',e.args)" 262 | ] 263 | }, 264 | { 265 | "cell_type": "code", 266 | "execution_count": null, 267 | "metadata": {}, 268 | "outputs": [], 269 | "source": [ 270 | "divofValues(1,0)" 271 | ] 272 | }, 273 | { 274 | "cell_type": "markdown", 275 | "metadata": {}, 276 | "source": [ 277 | "## The raise statement allows the programmer to force a specified exception to occur" 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": null, 283 | "metadata": {}, 284 | "outputs": [], 285 | "source": [ 286 | "def divofValues(x,y):\n", 287 | " try:\n", 288 | " raise ZeroDivisionError\n", 289 | " return x/y\n", 290 | " except TypeError:\n", 291 | " return ('Please provide integers')\n", 292 | " except ZeroDivisionError as e:\n", 293 | " return ('Denominator is 0',e.args)" 294 | ] 295 | }, 296 | { 297 | "cell_type": "code", 298 | "execution_count": null, 299 | "metadata": {}, 300 | "outputs": [], 301 | "source": [ 302 | "divofValues(1,0)" 303 | ] 304 | }, 305 | { 306 | "cell_type": "markdown", 307 | "metadata": {}, 308 | "source": [ 309 | "## Finally " 310 | ] 311 | }, 312 | { 313 | "cell_type": "markdown", 314 | "metadata": {}, 315 | "source": [ 316 | "If a finally clause is present, the finally clause will execute as the last task before the try statement completes. The finally clause runs whether or not the try statement produces an exception. The following points discuss more complex cases when an exception occurs:" 317 | ] 318 | }, 319 | { 320 | "cell_type": "code", 321 | "execution_count": null, 322 | "metadata": {}, 323 | "outputs": [], 324 | "source": [ 325 | "def divofValues(x,y):\n", 326 | " try:\n", 327 | "# raise KeyboardInterrupt\n", 328 | " return x/y\n", 329 | " except TypeError:\n", 330 | " return ('Please provide integers')\n", 331 | " except ZeroDivisionError as e:\n", 332 | " return ('Denominator is 0',e.args)\n", 333 | " finally:\n", 334 | " print ('Ok,bye')" 335 | ] 336 | }, 337 | { 338 | "cell_type": "code", 339 | "execution_count": null, 340 | "metadata": {}, 341 | "outputs": [], 342 | "source": [ 343 | "divofValues(1,0)" 344 | ] 345 | }, 346 | { 347 | "cell_type": "code", 348 | "execution_count": null, 349 | "metadata": {}, 350 | "outputs": [], 351 | "source": [ 352 | "def divofValues(x,y):\n", 353 | " try:\n", 354 | "# raise KeyboardInterrupt\n", 355 | " return x/y\n", 356 | " except TypeError:\n", 357 | " return ('Please provide integers')\n", 358 | " except ZeroDivisionError as e:\n", 359 | " return ('Denominator is 0',e.args)\n", 360 | " finally:\n", 361 | " return ('Ok,bye')" 362 | ] 363 | }, 364 | { 365 | "cell_type": "code", 366 | "execution_count": null, 367 | "metadata": {}, 368 | "outputs": [], 369 | "source": [ 370 | "divofValues(1,0)" 371 | ] 372 | }, 373 | { 374 | "cell_type": "markdown", 375 | "metadata": {}, 376 | "source": [ 377 | "If a finally clause includes a return statement, the finally clause’s return statement will execute before, and instead of, the return statement in a try clause" 378 | ] 379 | }, 380 | { 381 | "cell_type": "markdown", 382 | "metadata": {}, 383 | "source": [ 384 | "## Own generated Exceptions" 385 | ] 386 | }, 387 | { 388 | "cell_type": "markdown", 389 | "metadata": {}, 390 | "source": [ 391 | "Most exceptions are defined with names that end in “Error”, similar to the naming of the standard exceptions." 392 | ] 393 | }, 394 | { 395 | "cell_type": "code", 396 | "execution_count": null, 397 | "metadata": {}, 398 | "outputs": [], 399 | "source": [ 400 | "class GODError(Exception):\n", 401 | " pass\n", 402 | " \n", 403 | " def __init__(self, message):\n", 404 | " self.message = message" 405 | ] 406 | }, 407 | { 408 | "cell_type": "code", 409 | "execution_count": null, 410 | "metadata": {}, 411 | "outputs": [], 412 | "source": [ 413 | "GODError" 414 | ] 415 | }, 416 | { 417 | "cell_type": "code", 418 | "execution_count": null, 419 | "metadata": {}, 420 | "outputs": [], 421 | "source": [ 422 | "def divofValues(x,y):\n", 423 | " if x == 1:\n", 424 | " raise GODError('Value 1 given')\n", 425 | " try:\n", 426 | "# raise KeyboardInterrupt\n", 427 | " return x/y\n", 428 | " except GODError:\n", 429 | " return ('Please provide integers')" 430 | ] 431 | }, 432 | { 433 | "cell_type": "code", 434 | "execution_count": null, 435 | "metadata": {}, 436 | "outputs": [], 437 | "source": [ 438 | "divofValues(1,0)" 439 | ] 440 | }, 441 | { 442 | "cell_type": "code", 443 | "execution_count": null, 444 | "metadata": {}, 445 | "outputs": [], 446 | "source": [] 447 | } 448 | ], 449 | "metadata": { 450 | "kernelspec": { 451 | "display_name": "Python 3", 452 | "language": "python", 453 | "name": "python3" 454 | }, 455 | "language_info": { 456 | "codemirror_mode": { 457 | "name": "ipython", 458 | "version": 3 459 | }, 460 | "file_extension": ".py", 461 | "mimetype": "text/x-python", 462 | "name": "python", 463 | "nbconvert_exporter": "python", 464 | "pygments_lexer": "ipython3", 465 | "version": "3.6.9" 466 | } 467 | }, 468 | "nbformat": 4, 469 | "nbformat_minor": 2 470 | } 471 | -------------------------------------------------------------------------------- /instagramAutomation/so3.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/ANOVA-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# ANOVA" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": null, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import numpy as np" 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "metadata": {}, 22 | "source": [ 23 | "# Complete Randomized Design - - One way - ANOVA" 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": {}, 29 | "source": [ 30 | "## SST = SSC + SSE" 31 | ] 32 | }, 33 | { 34 | "cell_type": "markdown", 35 | "metadata": {}, 36 | "source": [ 37 | "$$ \\sum_{i=1}^{n_{j}}\\sum_{j=1}^{C}(x_{ij}- \\bar{x})^2 = \\sum_{j=1}^{C} n_{j}(\\bar{x}_{j} - \\bar{x} )^2 + \\sum_{i=1}^{n}\\sum_{j=1}^{C}(x_{ij}- \\bar{x_{j}})^2 $$" 38 | ] 39 | }, 40 | { 41 | "cell_type": "markdown", 42 | "metadata": {}, 43 | "source": [ 44 | "1. SST = total sum of squares\n", 45 | "2. SSC = sum of squares column\n", 46 | "3. SSE = sum of squares error" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": null, 52 | "metadata": {}, 53 | "outputs": [], 54 | "source": [ 55 | "sample1=np.random.randint(600,615,15)/10\n", 56 | "# sample2=sample3=sample4=sample5=sample1\n", 57 | "sample2=np.random.randint(600,615,14)/10\n", 58 | "sample3=np.random.randint(600,615,13)/10\n", 59 | "sample4=np.random.randint(600,615,15)/10\n", 60 | "sample5=np.random.randint(600,700,12)/10" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": null, 66 | "metadata": {}, 67 | "outputs": [], 68 | "source": [ 69 | "meansample1=sample1.mean()\n", 70 | "meansample2=sample2.mean()\n", 71 | "meansample3=sample3.mean()\n", 72 | "meansample4=sample4.mean()\n", 73 | "meansample5=sample5.mean()" 74 | ] 75 | }, 76 | { 77 | "cell_type": "code", 78 | "execution_count": null, 79 | "metadata": {}, 80 | "outputs": [], 81 | "source": [ 82 | "meansample1,meansample2,meansample3,meansample4,meansample5" 83 | ] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "execution_count": null, 88 | "metadata": {}, 89 | "outputs": [], 90 | "source": [ 91 | "overAllMean=(sum(sample1)+sum(sample2)+sum(sample3)+sum(sample4)+sum(sample5))/(len(sample1)+len(sample2)+len(sample3)+len(sample4)+len(sample5))" 92 | ] 93 | }, 94 | { 95 | "cell_type": "code", 96 | "execution_count": null, 97 | "metadata": {}, 98 | "outputs": [], 99 | "source": [ 100 | "overAllMean" 101 | ] 102 | }, 103 | { 104 | "cell_type": "markdown", 105 | "metadata": {}, 106 | "source": [ 107 | "# SST" 108 | ] 109 | }, 110 | { 111 | "cell_type": "code", 112 | "execution_count": null, 113 | "metadata": {}, 114 | "outputs": [], 115 | "source": [ 116 | "sqSumofTotal=np.sum([(overAllMean-i)**2 for i in sample1]+[(overAllMean-i)**2 for i in sample2]+\\\n", 117 | " [(overAllMean-i)**2 for i in sample3]+[(overAllMean-i)**2 for i in sample4]+\\\n", 118 | " [(overAllMean-i)**2 for i in sample5])" 119 | ] 120 | }, 121 | { 122 | "cell_type": "code", 123 | "execution_count": null, 124 | "metadata": {}, 125 | "outputs": [], 126 | "source": [ 127 | "sqSumofTotal" 128 | ] 129 | }, 130 | { 131 | "cell_type": "markdown", 132 | "metadata": {}, 133 | "source": [ 134 | "# SSC" 135 | ] 136 | }, 137 | { 138 | "cell_type": "code", 139 | "execution_count": null, 140 | "metadata": {}, 141 | "outputs": [], 142 | "source": [ 143 | "sqSumofColumns=len(sample1)*(meansample1-overAllMean)**2+\\\n", 144 | " len(sample2)*(meansample2-overAllMean)**2+\\\n", 145 | " len(sample3)*(meansample3-overAllMean)**2+\\\n", 146 | " len(sample4)*(meansample4-overAllMean)**2+\\\n", 147 | " len(sample5)*(meansample5-overAllMean)**2" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": null, 153 | "metadata": {}, 154 | "outputs": [], 155 | "source": [ 156 | "sqSumofColumns" 157 | ] 158 | }, 159 | { 160 | "cell_type": "markdown", 161 | "metadata": {}, 162 | "source": [ 163 | "## SSE" 164 | ] 165 | }, 166 | { 167 | "cell_type": "code", 168 | "execution_count": null, 169 | "metadata": {}, 170 | "outputs": [], 171 | "source": [ 172 | "sqSumofErrors=np.sum([(meansample1-i)**2 for i in sample1])+np.sum([(meansample2-i)**2 for i in sample2])+\\\n", 173 | " np.sum([(meansample3-i)**2 for i in sample3])+np.sum([(meansample4-i)**2 for i in sample4])+\\\n", 174 | " np.sum([(meansample5-i)**2 for i in sample5])" 175 | ] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "execution_count": null, 180 | "metadata": {}, 181 | "outputs": [], 182 | "source": [ 183 | "sqSumofErrors" 184 | ] 185 | }, 186 | { 187 | "cell_type": "markdown", 188 | "metadata": {}, 189 | "source": [ 190 | "\n", 191 | "Analysis of variance is used to determine statistically whether the variance between the categorical level means is greater than variance withing levels i.e error value.\n", 192 | "\n", 193 | "Severalimportant assumptions underlie analysis of variance:\n", 194 | "1. Observations are drawn from normally distributed populations.\n", 195 | "2. Observations represent random samples from the populations.\n", 196 | "3. Variances of the populations are equal." 197 | ] 198 | }, 199 | { 200 | "cell_type": "markdown", 201 | "metadata": {}, 202 | "source": [ 203 | "As shown previously, SST contains both SSC and SSE and can be partitioned into SSC and SSE. \n", 204 | "- MSC mean squares of column\n", 205 | "- MSE mean squares of error\n", 206 | "- MST mean squares total\n", 207 | "\n", 208 | "Mean square is an average and is computed by dividing the sum of squares by the degrees of freedom. Finally, the F value is determined by dividing the treatment variance (MSC) by the error variance (MSE). The F is a ratio of two variances. In the ANOVA situation, the F value is a ratio of the column variance to the error variance." 209 | ] 210 | }, 211 | { 212 | "cell_type": "code", 213 | "execution_count": null, 214 | "metadata": {}, 215 | "outputs": [], 216 | "source": [ 217 | "dofC=5-1\n", 218 | "dofE=(len(sample1)+len(sample2)+len(sample3)+len(sample4)+len(sample5))-5\n", 219 | "dofT=(len(sample1)+len(sample2)+len(sample3)+len(sample4)+len(sample5))-1" 220 | ] 221 | }, 222 | { 223 | "cell_type": "code", 224 | "execution_count": null, 225 | "metadata": {}, 226 | "outputs": [], 227 | "source": [ 228 | "MSC=sqSumofColumns/dofC\n", 229 | "MSE=sqSumofErrors/dofE" 230 | ] 231 | }, 232 | { 233 | "cell_type": "code", 234 | "execution_count": null, 235 | "metadata": {}, 236 | "outputs": [], 237 | "source": [ 238 | "MSC,MSE" 239 | ] 240 | }, 241 | { 242 | "cell_type": "code", 243 | "execution_count": null, 244 | "metadata": {}, 245 | "outputs": [], 246 | "source": [ 247 | "dofC,dofE" 248 | ] 249 | }, 250 | { 251 | "cell_type": "code", 252 | "execution_count": null, 253 | "metadata": {}, 254 | "outputs": [], 255 | "source": [ 256 | "fValueObserved=MSC/MSE" 257 | ] 258 | }, 259 | { 260 | "cell_type": "code", 261 | "execution_count": null, 262 | "metadata": {}, 263 | "outputs": [], 264 | "source": [ 265 | "fValueObserved" 266 | ] 267 | }, 268 | { 269 | "cell_type": "markdown", 270 | "metadata": {}, 271 | "source": [ 272 | "From these computations, an analysis of variance chart can be constructed. The observed F value is 66.24. It is compared to a critical value from the F table to determine whether there is a significant difference in treatment or classification." 273 | ] 274 | }, 275 | { 276 | "cell_type": "code", 277 | "execution_count": null, 278 | "metadata": {}, 279 | "outputs": [], 280 | "source": [ 281 | "fCritical= 3.01" 282 | ] 283 | }, 284 | { 285 | "cell_type": "markdown", 286 | "metadata": {}, 287 | "source": [ 288 | "## The null hypothesis is rejected" 289 | ] 290 | }, 291 | { 292 | "cell_type": "markdown", 293 | "metadata": {}, 294 | "source": [ 295 | "## Through Scipy " 296 | ] 297 | }, 298 | { 299 | "cell_type": "code", 300 | "execution_count": null, 301 | "metadata": {}, 302 | "outputs": [], 303 | "source": [ 304 | "import scipy.stats as st\n", 305 | "st.f_oneway(sample1,sample2,sample3,sample4,sample5)" 306 | ] 307 | }, 308 | { 309 | "cell_type": "markdown", 310 | "metadata": {}, 311 | "source": [ 312 | "# Randomized Block Design" 313 | ] 314 | }, 315 | { 316 | "cell_type": "markdown", 317 | "metadata": {}, 318 | "source": [ 319 | "$$ \\sum_{i=1}^{n_{j}}\\sum_{j=1}^{C}(x_{ij}- \\bar{x})^2 = n\\sum_{j=1}^{C}(\\bar{x}_{j} - \\bar{x} )^2 + \n", 320 | "C\\sum_{i=1}^{n}(\\bar{x_{i}}-\\bar{x}) +\n", 321 | "\\sum_{i=1}^{n}\\sum_{j=1}^{C}(x_{ij}- \\bar{x_{j}} -\\bar{x_{i}} + \\bar{x})^2 $$" 322 | ] 323 | }, 324 | { 325 | "cell_type": "markdown", 326 | "metadata": {}, 327 | "source": [ 328 | "1. SST = total sum of squares\n", 329 | "2. SSC = sum of squares column\n", 330 | "3. SSR = sum of squares of rows (Blocks)\n", 331 | "3. SSE = sum of squares error" 332 | ] 333 | }, 334 | { 335 | "cell_type": "markdown", 336 | "metadata": {}, 337 | "source": [ 338 | "- Row effects: \n", 339 | " - H0: Variable means all are equal.\n", 340 | " - Ha: At least one of the Variable means is different from the others.\n", 341 | "- Column effects: \n", 342 | " - H0: Block means are all equal.\n", 343 | " - Ha: At least one of the blocking means is different from the others." 344 | ] 345 | }, 346 | { 347 | "cell_type": "markdown", 348 | "metadata": {}, 349 | "source": [ 350 | "# Factorial Design" 351 | ] 352 | }, 353 | { 354 | "cell_type": "markdown", 355 | "metadata": {}, 356 | "source": [ 357 | "- Row effects: \n", 358 | " - H0: Row means all are equal.\n", 359 | " - Ha: At least one row mean is different from the others.\n", 360 | "- Column effects: \n", 361 | " - H0: Column means are all equal.\n", 362 | " - Ha: At least one column mean is different from the others.\n", 363 | "- Interaction effects: \n", 364 | " - H0: The interaction effects are zero.\n", 365 | " - Ha: An interaction effect is present." 366 | ] 367 | }, 368 | { 369 | "cell_type": "code", 370 | "execution_count": null, 371 | "metadata": {}, 372 | "outputs": [], 373 | "source": [ 374 | "import statsmodels.api as sm\n", 375 | "from statsmodels.formula.api import ols" 376 | ] 377 | }, 378 | { 379 | "cell_type": "code", 380 | "execution_count": null, 381 | "metadata": {}, 382 | "outputs": [], 383 | "source": [ 384 | "import pandas as pd\n", 385 | "data=pd.read_excel('Sample - Superstore.xls')" 386 | ] 387 | }, 388 | { 389 | "cell_type": "code", 390 | "execution_count": null, 391 | "metadata": {}, 392 | "outputs": [], 393 | "source": [ 394 | "data.head(2)" 395 | ] 396 | }, 397 | { 398 | "cell_type": "code", 399 | "execution_count": null, 400 | "metadata": {}, 401 | "outputs": [], 402 | "source": [ 403 | "pd.unique(data['Segment'])" 404 | ] 405 | }, 406 | { 407 | "cell_type": "markdown", 408 | "metadata": {}, 409 | "source": [ 410 | "# Randomized Block Design approach" 411 | ] 412 | }, 413 | { 414 | "cell_type": "code", 415 | "execution_count": null, 416 | "metadata": {}, 417 | "outputs": [], 418 | "source": [ 419 | "model = ols('Sales ~ C(Category) + C(Segment)', data=data).fit()" 420 | ] 421 | }, 422 | { 423 | "cell_type": "code", 424 | "execution_count": null, 425 | "metadata": {}, 426 | "outputs": [], 427 | "source": [ 428 | "anovaAnaRep = sm.stats.anova_lm(model, typ=2)\n", 429 | "anovaAnaRep" 430 | ] 431 | }, 432 | { 433 | "cell_type": "markdown", 434 | "metadata": {}, 435 | "source": [ 436 | "# Factorial Design (Interaction)" 437 | ] 438 | }, 439 | { 440 | "cell_type": "code", 441 | "execution_count": null, 442 | "metadata": {}, 443 | "outputs": [], 444 | "source": [ 445 | "model = ols('Sales ~ C(Category) + C(Segment) + C(Category):C(Segment)', data=data).fit()" 446 | ] 447 | }, 448 | { 449 | "cell_type": "code", 450 | "execution_count": null, 451 | "metadata": {}, 452 | "outputs": [], 453 | "source": [ 454 | "anovaAnaRep = sm.stats.anova_lm(model, typ=2)\n", 455 | "anovaAnaRep" 456 | ] 457 | }, 458 | { 459 | "cell_type": "code", 460 | "execution_count": null, 461 | "metadata": {}, 462 | "outputs": [], 463 | "source": [] 464 | }, 465 | { 466 | "cell_type": "code", 467 | "execution_count": null, 468 | "metadata": {}, 469 | "outputs": [], 470 | "source": [] 471 | }, 472 | { 473 | "cell_type": "code", 474 | "execution_count": null, 475 | "metadata": {}, 476 | "outputs": [], 477 | "source": [] 478 | }, 479 | { 480 | "cell_type": "code", 481 | "execution_count": null, 482 | "metadata": {}, 483 | "outputs": [], 484 | "source": [] 485 | }, 486 | { 487 | "cell_type": "code", 488 | "execution_count": null, 489 | "metadata": {}, 490 | "outputs": [], 491 | "source": [] 492 | } 493 | ], 494 | "metadata": { 495 | "kernelspec": { 496 | "display_name": "Python 3", 497 | "language": "python", 498 | "name": "python3" 499 | }, 500 | "language_info": { 501 | "codemirror_mode": { 502 | "name": "ipython", 503 | "version": 3 504 | }, 505 | "file_extension": ".py", 506 | "mimetype": "text/x-python", 507 | "name": "python", 508 | "nbconvert_exporter": "python", 509 | "pygments_lexer": "ipython3", 510 | "version": "3.6.9" 511 | } 512 | }, 513 | "nbformat": 4, 514 | "nbformat_minor": 2 515 | } 516 | -------------------------------------------------------------------------------- /selenium/Selenium.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## Installing and getting started" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "1. Install Selenium (https://www.selenium.dev/)\n", 15 | "2. Download Chrome/Firefox(geckodriver)/Safari/Chromium/ Drivers as of your choice \n", 16 | " - https://chromedriver.chromium.org/\n", 17 | "3. Select a website\n", 18 | " - http://example.webscraping.com/\n", 19 | " - https://webscraper.io/test-sites\n", 20 | " \n", 21 | "4. Getting started with Selenium" 22 | ] 23 | }, 24 | { 25 | "cell_type": "markdown", 26 | "metadata": {}, 27 | "source": [ 28 | "# Getting started" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": 1, 34 | "metadata": {}, 35 | "outputs": [], 36 | "source": [ 37 | "import selenium\n", 38 | "from selenium import webdriver as wb" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": 2, 44 | "metadata": {}, 45 | "outputs": [], 46 | "source": [ 47 | "webD=wb.Chrome('chromedriver.exe')" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 3, 53 | "metadata": {}, 54 | "outputs": [], 55 | "source": [ 56 | "webD.get('https://www.google.com')" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "# Navigating the Page" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "metadata": {}, 69 | "source": [ 70 | "The page element will have \"Name\", \"Class\", \"Id\", \"xpath\" or some other kind of identifier" 71 | ] 72 | }, 73 | { 74 | "cell_type": "markdown", 75 | "metadata": {}, 76 | "source": [ 77 | "## Finding element by name" 78 | ] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "execution_count": null, 83 | "metadata": {}, 84 | "outputs": [], 85 | "source": [ 86 | "ele1=webD.find_element_by_name('q')" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": null, 92 | "metadata": {}, 93 | "outputs": [], 94 | "source": [ 95 | "ele1.send_keys('Web Scraping')" 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": null, 101 | "metadata": {}, 102 | "outputs": [], 103 | "source": [ 104 | "btnEle=webD.find_element_by_name('btnK')" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": null, 110 | "metadata": {}, 111 | "outputs": [], 112 | "source": [ 113 | "btnEle.click()" 114 | ] 115 | }, 116 | { 117 | "cell_type": "markdown", 118 | "metadata": {}, 119 | "source": [ 120 | "## Finding element by xpath" 121 | ] 122 | }, 123 | { 124 | "cell_type": "code", 125 | "execution_count": null, 126 | "metadata": {}, 127 | "outputs": [], 128 | "source": [ 129 | "//*[@id=\"tsf\"]/div[2]/div[1]/div[1]/div/div[2]/input" 130 | ] 131 | }, 132 | { 133 | "cell_type": "code", 134 | "execution_count": null, 135 | "metadata": {}, 136 | "outputs": [], 137 | "source": [ 138 | "eleXP=webD.find_element_by_xpath('//*[@id=\"tsf\"]/div[2]/div[1]/div[1]/div/div[2]/input')" 139 | ] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "execution_count": null, 144 | "metadata": {}, 145 | "outputs": [], 146 | "source": [ 147 | "eleXP.send_keys('Web Scraping')" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": null, 153 | "metadata": {}, 154 | "outputs": [], 155 | "source": [ 156 | "btnEXpa=webD.find_element_by_xpath('//*[@id=\"tsf\"]/div[2]/div[1]/div[3]/center/input[1]')\n", 157 | "btnEXpa.click()" 158 | ] 159 | }, 160 | { 161 | "cell_type": "markdown", 162 | "metadata": {}, 163 | "source": [ 164 | "## Finding element by Class" 165 | ] 166 | }, 167 | { 168 | "cell_type": "code", 169 | "execution_count": 4, 170 | "metadata": {}, 171 | "outputs": [], 172 | "source": [ 173 | "eleCla=webD.find_element_by_class_name('SDkEP')" 174 | ] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": 5, 179 | "metadata": {}, 180 | "outputs": [], 181 | "source": [ 182 | "eleCla2=eleCla.find_element_by_class_name('a4bIc')" 183 | ] 184 | }, 185 | { 186 | "cell_type": "code", 187 | "execution_count": 6, 188 | "metadata": {}, 189 | "outputs": [], 190 | "source": [ 191 | "eleCla2Div=eleCla2.find_element_by_css_selector('input')" 192 | ] 193 | }, 194 | { 195 | "cell_type": "code", 196 | "execution_count": 7, 197 | "metadata": {}, 198 | "outputs": [], 199 | "source": [ 200 | "eleCla2Div.send_keys('Web Scraping')" 201 | ] 202 | }, 203 | { 204 | "cell_type": "code", 205 | "execution_count": 8, 206 | "metadata": {}, 207 | "outputs": [ 208 | { 209 | "data": { 210 | "text/plain": [ 211 | "" 212 | ] 213 | }, 214 | "execution_count": 8, 215 | "metadata": {}, 216 | "output_type": "execute_result" 217 | } 218 | ], 219 | "source": [ 220 | "webD.find_element_by_class_name('FPdoLc')" 221 | ] 222 | }, 223 | { 224 | "cell_type": "code", 225 | "execution_count": 9, 226 | "metadata": {}, 227 | "outputs": [], 228 | "source": [ 229 | "centeEle=webD.find_element_by_css_selector('center')" 230 | ] 231 | }, 232 | { 233 | "cell_type": "code", 234 | "execution_count": 10, 235 | "metadata": {}, 236 | "outputs": [], 237 | "source": [ 238 | "searhEle=centeEle.find_element_by_class_name('gNO89b')" 239 | ] 240 | }, 241 | { 242 | "cell_type": "code", 243 | "execution_count": 11, 244 | "metadata": {}, 245 | "outputs": [], 246 | "source": [ 247 | "searhEle.click()" 248 | ] 249 | }, 250 | { 251 | "cell_type": "markdown", 252 | "metadata": {}, 253 | "source": [ 254 | "## Some other methods like" 255 | ] 256 | }, 257 | { 258 | "cell_type": "markdown", 259 | "metadata": {}, 260 | "source": [ 261 | "## webD.find_element_by_id, webD.find_element_by_tag_name" 262 | ] 263 | }, 264 | { 265 | "cell_type": "markdown", 266 | "metadata": {}, 267 | "source": [ 268 | "# Filling forms using selenium\n", 269 | "\n", 270 | "https://forms.gle/LRYwqvGx1Uhq5qYt5" 271 | ] 272 | }, 273 | { 274 | "cell_type": "code", 275 | "execution_count": 24, 276 | "metadata": {}, 277 | "outputs": [], 278 | "source": [ 279 | "import selenium\n", 280 | "from selenium import webdriver as wb\n", 281 | "webD=wb.Chrome('chromedriver.exe')\n", 282 | "webD.get('https://forms.gle/LRYwqvGx1Uhq5qYt5')" 283 | ] 284 | }, 285 | { 286 | "cell_type": "code", 287 | "execution_count": 25, 288 | "metadata": {}, 289 | "outputs": [], 290 | "source": [ 291 | "question2=webD.find_element_by_xpath('//*[@id=\"mG61Hd\"]/div/div/div[2]/div[2]/div/div[2]/div')" 292 | ] 293 | }, 294 | { 295 | "cell_type": "code", 296 | "execution_count": 26, 297 | "metadata": {}, 298 | "outputs": [], 299 | "source": [ 300 | "question2Ele=question2.find_element_by_xpath('//*[@id=\"mG61Hd\"]/div/div/div[2]/div[2]/div/div[2]/div/span')" 301 | ] 302 | }, 303 | { 304 | "cell_type": "code", 305 | "execution_count": 27, 306 | "metadata": {}, 307 | "outputs": [ 308 | { 309 | "data": { 310 | "text/plain": [ 311 | "'Scraping\\nData Science\\nOther:'" 312 | ] 313 | }, 314 | "execution_count": 27, 315 | "metadata": {}, 316 | "output_type": "execute_result" 317 | } 318 | ], 319 | "source": [ 320 | "question2Ele.text" 321 | ] 322 | }, 323 | { 324 | "cell_type": "code", 325 | "execution_count": 28, 326 | "metadata": {}, 327 | "outputs": [], 328 | "source": [ 329 | "optionEle=question2Ele.find_element_by_class_name('freebirdFormviewerViewItemsRadioChoicesContainer')" 330 | ] 331 | }, 332 | { 333 | "cell_type": "code", 334 | "execution_count": 29, 335 | "metadata": {}, 336 | "outputs": [], 337 | "source": [ 338 | "eleOptions=optionEle.find_elements_by_class_name('freebirdFormviewerViewItemsRadioOptionContainer')" 339 | ] 340 | }, 341 | { 342 | "cell_type": "code", 343 | "execution_count": 30, 344 | "metadata": {}, 345 | "outputs": [ 346 | { 347 | "name": "stdout", 348 | "output_type": "stream", 349 | "text": [ 350 | "Scraping\n", 351 | "Data Science\n", 352 | "Other:\n" 353 | ] 354 | } 355 | ], 356 | "source": [ 357 | "for i in eleOptions:\n", 358 | " print(i.text)" 359 | ] 360 | }, 361 | { 362 | "cell_type": "code", 363 | "execution_count": 31, 364 | "metadata": {}, 365 | "outputs": [], 366 | "source": [ 367 | "for el in eleOptions:\n", 368 | " if el.text == 'Scraping':\n", 369 | " el.click()" 370 | ] 371 | }, 372 | { 373 | "cell_type": "code", 374 | "execution_count": null, 375 | "metadata": {}, 376 | "outputs": [], 377 | "source": [] 378 | }, 379 | { 380 | "cell_type": "markdown", 381 | "metadata": {}, 382 | "source": [ 383 | "## Select element in Selenium" 384 | ] 385 | }, 386 | { 387 | "cell_type": "code", 388 | "execution_count": null, 389 | "metadata": {}, 390 | "outputs": [], 391 | "source": [ 392 | "from selenium.webdriver.support.ui import Select\n", 393 | "import selenium\n", 394 | "from selenium import webdriver as wb\n", 395 | "webD=wb.Chrome('chromedriver.exe')\n", 396 | "webD.get('https://forms.gle/LRYwqvGx1Uhq5qYt5')\n" 397 | ] 398 | }, 399 | { 400 | "cell_type": "code", 401 | "execution_count": null, 402 | "metadata": {}, 403 | "outputs": [], 404 | "source": [ 405 | "question2=webD.find_element_by_xpath('//*[@id=\"mG61Hd\"]/div/div/div[2]/div[2]/div/div[2]/div')\n", 406 | "optionEle=question2.find_element_by_class_name('freebirdFormviewerViewItemsRadioChoicesContainer')\n", 407 | "eleOptions=optionEle.find_elements_by_class_name('freebirdFormviewerViewItemsRadioOptionContainer')" 408 | ] 409 | }, 410 | { 411 | "cell_type": "code", 412 | "execution_count": null, 413 | "metadata": {}, 414 | "outputs": [], 415 | "source": [ 416 | "www=webD.find_element_by_xpath('//*[@id=\"mG61Hd\"]/div/div/div[2]/div[3]/div/div[2]')" 417 | ] 418 | }, 419 | { 420 | "cell_type": "code", 421 | "execution_count": null, 422 | "metadata": {}, 423 | "outputs": [], 424 | "source": [ 425 | "Select(www)" 426 | ] 427 | }, 428 | { 429 | "cell_type": "markdown", 430 | "metadata": {}, 431 | "source": [ 432 | "## Action Chain\n", 433 | "\n", 434 | "ActionChains are a way to automate low level interactions such as mouse movements, mouse button actions, key press, and context menu interactions. This is useful for doing more complex actions like hover over and drag and drop.\n", 435 | "\n", 436 | "Drag and Drop" 437 | ] 438 | }, 439 | { 440 | "cell_type": "code", 441 | "execution_count": 46, 442 | "metadata": {}, 443 | "outputs": [], 444 | "source": [ 445 | "from selenium.webdriver import ActionChains\n", 446 | "import selenium\n", 447 | "from selenium import webdriver as wb\n", 448 | "webD=wb.Chrome('chromedriver.exe')\n", 449 | "# webD=wb.Firefox('C:/Users/swsh/Desktop/selenium_Tutorial/')\n", 450 | "# webD.get('https://www.w3schools.com/html/html5_draganddrop.asp')\n", 451 | "webD.get('http://dhtmlgoodies.com/scripts/drag-drop-custom/demo-drag-drop-3.html')" 452 | ] 453 | }, 454 | { 455 | "cell_type": "code", 456 | "execution_count": 47, 457 | "metadata": {}, 458 | "outputs": [], 459 | "source": [ 460 | "element = webD.find_element_by_xpath('//*[@id=\"box7\"]')" 461 | ] 462 | }, 463 | { 464 | "cell_type": "code", 465 | "execution_count": 48, 466 | "metadata": {}, 467 | "outputs": [], 468 | "source": [ 469 | "target = webD.find_element_by_xpath('//*[@id=\"box107\"]')" 470 | ] 471 | }, 472 | { 473 | "cell_type": "code", 474 | "execution_count": 49, 475 | "metadata": {}, 476 | "outputs": [], 477 | "source": [ 478 | "action_chains = ActionChains(webD)" 479 | ] 480 | }, 481 | { 482 | "cell_type": "code", 483 | "execution_count": 45, 484 | "metadata": {}, 485 | "outputs": [], 486 | "source": [ 487 | "action_chains.drag_and_drop(element,target).perform()" 488 | ] 489 | }, 490 | { 491 | "cell_type": "code", 492 | "execution_count": 50, 493 | "metadata": {}, 494 | "outputs": [], 495 | "source": [ 496 | "action_chains.click_and_hold(element).move_to_element(target).release(target).perform()" 497 | ] 498 | }, 499 | { 500 | "cell_type": "markdown", 501 | "metadata": {}, 502 | "source": [ 503 | "## Taking a screenshot of a window" 504 | ] 505 | }, 506 | { 507 | "cell_type": "code", 508 | "execution_count": 51, 509 | "metadata": {}, 510 | "outputs": [], 511 | "source": [ 512 | "scShot=webD.get_screenshot_as_png()" 513 | ] 514 | }, 515 | { 516 | "cell_type": "code", 517 | "execution_count": 52, 518 | "metadata": {}, 519 | "outputs": [], 520 | "source": [ 521 | "with open('somefile.png','wb') as f:\n", 522 | " f.write(scShot)" 523 | ] 524 | }, 525 | { 526 | "cell_type": "code", 527 | "execution_count": null, 528 | "metadata": {}, 529 | "outputs": [], 530 | "source": [ 531 | "webD.fin" 532 | ] 533 | } 534 | ], 535 | "metadata": { 536 | "kernelspec": { 537 | "display_name": "Python 3", 538 | "language": "python", 539 | "name": "python3" 540 | }, 541 | "language_info": { 542 | "codemirror_mode": { 543 | "name": "ipython", 544 | "version": 3 545 | }, 546 | "file_extension": ".py", 547 | "mimetype": "text/x-python", 548 | "name": "python", 549 | "nbconvert_exporter": "python", 550 | "pygments_lexer": "ipython3", 551 | "version": "3.6.9" 552 | } 553 | }, 554 | "nbformat": 4, 555 | "nbformat_minor": 2 556 | } 557 | -------------------------------------------------------------------------------- /selenium/.ipynb_checkpoints/Selenium-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## Installing and getting started" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "1. Install Selenium (https://www.selenium.dev/)\n", 15 | "2. Download Chrome/Firefox(geckodriver)/Safari/Chromium/ Drivers as of your choice \n", 16 | " - https://chromedriver.chromium.org/\n", 17 | "3. Select a website\n", 18 | " - http://example.webscraping.com/\n", 19 | " - https://webscraper.io/test-sites\n", 20 | " \n", 21 | "4. Getting started with Selenium" 22 | ] 23 | }, 24 | { 25 | "cell_type": "markdown", 26 | "metadata": {}, 27 | "source": [ 28 | "# Getting started" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": 1, 34 | "metadata": {}, 35 | "outputs": [], 36 | "source": [ 37 | "import selenium\n", 38 | "from selenium import webdriver as wb" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": 2, 44 | "metadata": {}, 45 | "outputs": [], 46 | "source": [ 47 | "webD=wb.Chrome('chromedriver.exe')" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 3, 53 | "metadata": {}, 54 | "outputs": [], 55 | "source": [ 56 | "webD.get('https://www.google.com')" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "# Navigating the Page" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "metadata": {}, 69 | "source": [ 70 | "The page element will have \"Name\", \"Class\", \"Id\", \"xpath\" or some other kind of identifier" 71 | ] 72 | }, 73 | { 74 | "cell_type": "markdown", 75 | "metadata": {}, 76 | "source": [ 77 | "## Finding element by name" 78 | ] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "execution_count": null, 83 | "metadata": {}, 84 | "outputs": [], 85 | "source": [ 86 | "ele1=webD.find_element_by_name('q')" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": null, 92 | "metadata": {}, 93 | "outputs": [], 94 | "source": [ 95 | "ele1.send_keys('Web Scraping')" 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": null, 101 | "metadata": {}, 102 | "outputs": [], 103 | "source": [ 104 | "btnEle=webD.find_element_by_name('btnK')" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": null, 110 | "metadata": {}, 111 | "outputs": [], 112 | "source": [ 113 | "btnEle.click()" 114 | ] 115 | }, 116 | { 117 | "cell_type": "markdown", 118 | "metadata": {}, 119 | "source": [ 120 | "## Finding element by xpath" 121 | ] 122 | }, 123 | { 124 | "cell_type": "code", 125 | "execution_count": null, 126 | "metadata": {}, 127 | "outputs": [], 128 | "source": [ 129 | "//*[@id=\"tsf\"]/div[2]/div[1]/div[1]/div/div[2]/input" 130 | ] 131 | }, 132 | { 133 | "cell_type": "code", 134 | "execution_count": null, 135 | "metadata": {}, 136 | "outputs": [], 137 | "source": [ 138 | "eleXP=webD.find_element_by_xpath('//*[@id=\"tsf\"]/div[2]/div[1]/div[1]/div/div[2]/input')" 139 | ] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "execution_count": null, 144 | "metadata": {}, 145 | "outputs": [], 146 | "source": [ 147 | "eleXP.send_keys('Web Scraping')" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": null, 153 | "metadata": {}, 154 | "outputs": [], 155 | "source": [ 156 | "btnEXpa=webD.find_element_by_xpath('//*[@id=\"tsf\"]/div[2]/div[1]/div[3]/center/input[1]')\n", 157 | "btnEXpa.click()" 158 | ] 159 | }, 160 | { 161 | "cell_type": "markdown", 162 | "metadata": {}, 163 | "source": [ 164 | "## Finding element by Class" 165 | ] 166 | }, 167 | { 168 | "cell_type": "code", 169 | "execution_count": 4, 170 | "metadata": {}, 171 | "outputs": [], 172 | "source": [ 173 | "eleCla=webD.find_element_by_class_name('SDkEP')" 174 | ] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": 5, 179 | "metadata": {}, 180 | "outputs": [], 181 | "source": [ 182 | "eleCla2=eleCla.find_element_by_class_name('a4bIc')" 183 | ] 184 | }, 185 | { 186 | "cell_type": "code", 187 | "execution_count": 6, 188 | "metadata": {}, 189 | "outputs": [], 190 | "source": [ 191 | "eleCla2Div=eleCla2.find_element_by_css_selector('input')" 192 | ] 193 | }, 194 | { 195 | "cell_type": "code", 196 | "execution_count": 7, 197 | "metadata": {}, 198 | "outputs": [], 199 | "source": [ 200 | "eleCla2Div.send_keys('Web Scraping')" 201 | ] 202 | }, 203 | { 204 | "cell_type": "code", 205 | "execution_count": 8, 206 | "metadata": {}, 207 | "outputs": [ 208 | { 209 | "data": { 210 | "text/plain": [ 211 | "" 212 | ] 213 | }, 214 | "execution_count": 8, 215 | "metadata": {}, 216 | "output_type": "execute_result" 217 | } 218 | ], 219 | "source": [ 220 | "webD.find_element_by_class_name('FPdoLc')" 221 | ] 222 | }, 223 | { 224 | "cell_type": "code", 225 | "execution_count": 9, 226 | "metadata": {}, 227 | "outputs": [], 228 | "source": [ 229 | "centeEle=webD.find_element_by_css_selector('center')" 230 | ] 231 | }, 232 | { 233 | "cell_type": "code", 234 | "execution_count": 10, 235 | "metadata": {}, 236 | "outputs": [], 237 | "source": [ 238 | "searhEle=centeEle.find_element_by_class_name('gNO89b')" 239 | ] 240 | }, 241 | { 242 | "cell_type": "code", 243 | "execution_count": 11, 244 | "metadata": {}, 245 | "outputs": [], 246 | "source": [ 247 | "searhEle.click()" 248 | ] 249 | }, 250 | { 251 | "cell_type": "markdown", 252 | "metadata": {}, 253 | "source": [ 254 | "## Some other methods like" 255 | ] 256 | }, 257 | { 258 | "cell_type": "markdown", 259 | "metadata": {}, 260 | "source": [ 261 | "## webD.find_element_by_id, webD.find_element_by_tag_name" 262 | ] 263 | }, 264 | { 265 | "cell_type": "markdown", 266 | "metadata": {}, 267 | "source": [ 268 | "# Filling forms using selenium\n", 269 | "\n", 270 | "https://forms.gle/LRYwqvGx1Uhq5qYt5" 271 | ] 272 | }, 273 | { 274 | "cell_type": "code", 275 | "execution_count": 24, 276 | "metadata": {}, 277 | "outputs": [], 278 | "source": [ 279 | "import selenium\n", 280 | "from selenium import webdriver as wb\n", 281 | "webD=wb.Chrome('chromedriver.exe')\n", 282 | "webD.get('https://forms.gle/LRYwqvGx1Uhq5qYt5')" 283 | ] 284 | }, 285 | { 286 | "cell_type": "code", 287 | "execution_count": 25, 288 | "metadata": {}, 289 | "outputs": [], 290 | "source": [ 291 | "question2=webD.find_element_by_xpath('//*[@id=\"mG61Hd\"]/div/div/div[2]/div[2]/div/div[2]/div')" 292 | ] 293 | }, 294 | { 295 | "cell_type": "code", 296 | "execution_count": 26, 297 | "metadata": {}, 298 | "outputs": [], 299 | "source": [ 300 | "question2Ele=question2.find_element_by_xpath('//*[@id=\"mG61Hd\"]/div/div/div[2]/div[2]/div/div[2]/div/span')" 301 | ] 302 | }, 303 | { 304 | "cell_type": "code", 305 | "execution_count": 27, 306 | "metadata": {}, 307 | "outputs": [ 308 | { 309 | "data": { 310 | "text/plain": [ 311 | "'Scraping\\nData Science\\nOther:'" 312 | ] 313 | }, 314 | "execution_count": 27, 315 | "metadata": {}, 316 | "output_type": "execute_result" 317 | } 318 | ], 319 | "source": [ 320 | "question2Ele.text" 321 | ] 322 | }, 323 | { 324 | "cell_type": "code", 325 | "execution_count": 28, 326 | "metadata": {}, 327 | "outputs": [], 328 | "source": [ 329 | "optionEle=question2Ele.find_element_by_class_name('freebirdFormviewerViewItemsRadioChoicesContainer')" 330 | ] 331 | }, 332 | { 333 | "cell_type": "code", 334 | "execution_count": 29, 335 | "metadata": {}, 336 | "outputs": [], 337 | "source": [ 338 | "eleOptions=optionEle.find_elements_by_class_name('freebirdFormviewerViewItemsRadioOptionContainer')" 339 | ] 340 | }, 341 | { 342 | "cell_type": "code", 343 | "execution_count": 30, 344 | "metadata": {}, 345 | "outputs": [ 346 | { 347 | "name": "stdout", 348 | "output_type": "stream", 349 | "text": [ 350 | "Scraping\n", 351 | "Data Science\n", 352 | "Other:\n" 353 | ] 354 | } 355 | ], 356 | "source": [ 357 | "for i in eleOptions:\n", 358 | " print(i.text)" 359 | ] 360 | }, 361 | { 362 | "cell_type": "code", 363 | "execution_count": 31, 364 | "metadata": {}, 365 | "outputs": [], 366 | "source": [ 367 | "for el in eleOptions:\n", 368 | " if el.text == 'Scraping':\n", 369 | " el.click()" 370 | ] 371 | }, 372 | { 373 | "cell_type": "code", 374 | "execution_count": null, 375 | "metadata": {}, 376 | "outputs": [], 377 | "source": [] 378 | }, 379 | { 380 | "cell_type": "markdown", 381 | "metadata": {}, 382 | "source": [ 383 | "## Select element in Selenium" 384 | ] 385 | }, 386 | { 387 | "cell_type": "code", 388 | "execution_count": null, 389 | "metadata": {}, 390 | "outputs": [], 391 | "source": [ 392 | "from selenium.webdriver.support.ui import Select\n", 393 | "import selenium\n", 394 | "from selenium import webdriver as wb\n", 395 | "webD=wb.Chrome('chromedriver.exe')\n", 396 | "webD.get('https://forms.gle/LRYwqvGx1Uhq5qYt5')\n" 397 | ] 398 | }, 399 | { 400 | "cell_type": "code", 401 | "execution_count": null, 402 | "metadata": {}, 403 | "outputs": [], 404 | "source": [ 405 | "question2=webD.find_element_by_xpath('//*[@id=\"mG61Hd\"]/div/div/div[2]/div[2]/div/div[2]/div')\n", 406 | "optionEle=question2.find_element_by_class_name('freebirdFormviewerViewItemsRadioChoicesContainer')\n", 407 | "eleOptions=optionEle.find_elements_by_class_name('freebirdFormviewerViewItemsRadioOptionContainer')" 408 | ] 409 | }, 410 | { 411 | "cell_type": "code", 412 | "execution_count": null, 413 | "metadata": {}, 414 | "outputs": [], 415 | "source": [ 416 | "www=webD.find_element_by_xpath('//*[@id=\"mG61Hd\"]/div/div/div[2]/div[3]/div/div[2]')" 417 | ] 418 | }, 419 | { 420 | "cell_type": "code", 421 | "execution_count": null, 422 | "metadata": {}, 423 | "outputs": [], 424 | "source": [ 425 | "Select(www)" 426 | ] 427 | }, 428 | { 429 | "cell_type": "markdown", 430 | "metadata": {}, 431 | "source": [ 432 | "## Action Chain\n", 433 | "\n", 434 | "ActionChains are a way to automate low level interactions such as mouse movements, mouse button actions, key press, and context menu interactions. This is useful for doing more complex actions like hover over and drag and drop.\n", 435 | "\n", 436 | "Drag and Drop" 437 | ] 438 | }, 439 | { 440 | "cell_type": "code", 441 | "execution_count": 46, 442 | "metadata": {}, 443 | "outputs": [], 444 | "source": [ 445 | "from selenium.webdriver import ActionChains\n", 446 | "import selenium\n", 447 | "from selenium import webdriver as wb\n", 448 | "webD=wb.Chrome('chromedriver.exe')\n", 449 | "# webD=wb.Firefox('C:/Users/swsh/Desktop/selenium_Tutorial/')\n", 450 | "# webD.get('https://www.w3schools.com/html/html5_draganddrop.asp')\n", 451 | "webD.get('http://dhtmlgoodies.com/scripts/drag-drop-custom/demo-drag-drop-3.html')" 452 | ] 453 | }, 454 | { 455 | "cell_type": "code", 456 | "execution_count": 47, 457 | "metadata": {}, 458 | "outputs": [], 459 | "source": [ 460 | "element = webD.find_element_by_xpath('//*[@id=\"box7\"]')" 461 | ] 462 | }, 463 | { 464 | "cell_type": "code", 465 | "execution_count": 48, 466 | "metadata": {}, 467 | "outputs": [], 468 | "source": [ 469 | "target = webD.find_element_by_xpath('//*[@id=\"box107\"]')" 470 | ] 471 | }, 472 | { 473 | "cell_type": "code", 474 | "execution_count": 49, 475 | "metadata": {}, 476 | "outputs": [], 477 | "source": [ 478 | "action_chains = ActionChains(webD)" 479 | ] 480 | }, 481 | { 482 | "cell_type": "code", 483 | "execution_count": 45, 484 | "metadata": {}, 485 | "outputs": [], 486 | "source": [ 487 | "action_chains.drag_and_drop(element,target).perform()" 488 | ] 489 | }, 490 | { 491 | "cell_type": "code", 492 | "execution_count": 50, 493 | "metadata": {}, 494 | "outputs": [], 495 | "source": [ 496 | "action_chains.click_and_hold(element).move_to_element(target).release(target).perform()" 497 | ] 498 | }, 499 | { 500 | "cell_type": "markdown", 501 | "metadata": {}, 502 | "source": [ 503 | "## Taking a screenshot of a window" 504 | ] 505 | }, 506 | { 507 | "cell_type": "code", 508 | "execution_count": 51, 509 | "metadata": {}, 510 | "outputs": [], 511 | "source": [ 512 | "scShot=webD.get_screenshot_as_png()" 513 | ] 514 | }, 515 | { 516 | "cell_type": "code", 517 | "execution_count": 52, 518 | "metadata": {}, 519 | "outputs": [], 520 | "source": [ 521 | "with open('somefile.png','wb') as f:\n", 522 | " f.write(scShot)" 523 | ] 524 | }, 525 | { 526 | "cell_type": "code", 527 | "execution_count": null, 528 | "metadata": {}, 529 | "outputs": [], 530 | "source": [ 531 | "webD.fin" 532 | ] 533 | } 534 | ], 535 | "metadata": { 536 | "kernelspec": { 537 | "display_name": "Python 3", 538 | "language": "python", 539 | "name": "python3" 540 | }, 541 | "language_info": { 542 | "codemirror_mode": { 543 | "name": "ipython", 544 | "version": 3 545 | }, 546 | "file_extension": ".py", 547 | "mimetype": "text/x-python", 548 | "name": "python", 549 | "nbconvert_exporter": "python", 550 | "pygments_lexer": "ipython3", 551 | "version": "3.6.9" 552 | } 553 | }, 554 | "nbformat": 4, 555 | "nbformat_minor": 2 556 | } 557 | -------------------------------------------------------------------------------- /instagramAutomation/someHier.xml: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------------