Posts

Showing posts from 2020

Python data science questions- Basic

1) randomly select an element from list- import random foo = [ 'a' , 'b' , 'c' , 'd' , 'e' ] print ( random . choice ( foo )) 2) Package to control key board and mouse in python- Pynput 3) Package to interact with web pages in Python- Selenium, webbrowser 4) Package for creating API is python -Flask

open multiple sites in python Script using web browser package

including required packages- ! pip install random ! pip install webbrowser import random import webbrowser import os adding multiple sites in a list- ls=['/2016/08/business-analytics-on-sales-data-of.html', '/recommendation-engine-market-basket.html', '/2016/08/optimizing-e-commerce-site-using.html'    ,'/2016/08/8-simple-ways-to-increse-your-blog.html', '/2016/08/business-analytics-on-sales-data-of.html',    '/2017/12/gaussian-state-space-model-in-r-using.html', '/2017/09/assumptions-of-linear-regression.html',    '/2017/09/neural-network-forward-propagation-in.html', '/2018/06/lda-linear-discriminant-analysis-where.html',    '/2018/10/religious-demographics-of-india-in.html', '/2020/04/forecasting-total-deaths-from.html',    '/2019/11/automatic-ticket-resolution-for.html', '/2019/09/sentiment-analysis-using-nltk-and.html', '/2019/07/deep-learning-with-h2o-in-py...

Automatically open and do some actions on web pages in python using different packages

1) Automatically open web url using Selenium- get chrome driver from here- https://chromedriver.storage.googleapis.com/index.html?path=80.0.3987.106  place the chrome driver in user/username/bin location from selenium import webdriver browser = webdriver.Chrome(executable_path = '/Users/abcarp/bin/chromedriver') browser.get('https://in.linkedin.com/') sleep(10) browser.close() 2) Automatically login to Linkedin and do some action using selenium- from selenium.webdriver.common.keys import Keys      # url of LinkedIn  url = "https://www.linkedin.com/login?fromSignIn=true&trk=guest_homepage-basic_nav-header-signin"   # path to browser web driver  driver = webdriver.Chrome( '/Users/esisarp/bin/chromedriver')       driver.get(url)  # getting the user-name element username = driver.find_element_by_id("username")   # Sending the keys for username        username.s...