Posts

How to scrape data and automate things using selenium.

Image
  Selenium : The  selenium  package is used to automate web browser interaction from Python. Python language bindings for Selenium WebDriver. Supported Python versions for Selenium are 2.7 and 3.5+.   Selenium requires a driver to interface with the chosen browser. Selenium server is a Java program. Java Runtime Environment (JRE) 1.6 or a newer version is recommended to run the Selenium server. To install selenium:  pip install selenium   The  selenium.webdriver  module provides all the WebDriver implementations. Currently supported WebDriver implementations are Firefox, Chrome, IE, and Remote. The  Keys  class provides keys in the keyboard like RETURN, F1, ALT, etc.   What is a web driver?  WebDriver drives a browser natively, as a user would, either locally or on a remote machine using the Selenium server, marks a leap forward in terms of browser automation. Selenium WebDriver refers to both the language bindings an...

An important concept regarding machine learning.

Image
  Distribution: Distribution shows us how the probabilities of measurements are distributed. 1. Normal Distribution:- Normal distribution is always centered on the average value.     Standard Deviation:  The width of the curve defines the ' standard deviation' . It is called a central limit theorem. Width of the mean value.    Mean ( x̅   ):  Center value or average value of the distribution. Both represent the population called as Population Parameter . The parameters that determine how a distribution fits the population data are called  Population Parameters .  2. Exponential Distribution:- It is also used for probabilities and statistics. 3. Gamma Distribution:- It is also used for probabilities and statistics. In this type of distribution, shape and rate are parameters. Variance:   OR Standard Deviation:   Model: A model  is a way to explore a relationship. We use statistics to determine how useful and how re...

How to perform operations on emails and folders using imap_tools?

Image
  IMAP_TOOLS: imap_tools is a library used to perform operations on emails and folders. Installation: pip install imap-tools How to log in to the mail?  We need to pass the username and password to the login function. And also we can pass the initial_folder name. How to get subjects from a specific folder?   First searches email nums by criteria in the current folder, then fetch and yields. E-mail attributes:  You can fetch the required data of e-mail using email attributes. Like you can fetch sender of mail using from_ attribute. You can easily fetch the date of mail using date attributes.  There are lots of e-mail attributes, we see some of them. Search criteria: You can use three approaches to build search criteria.  Search using subject. Search using text. Search using charset. AND, OR, NOT, Header and UidRange these classes are used for search logic. How to perform actions on email? You can perform the following operations on email:  cop...

How to perform calculations with fractions or number's in Python

Image
Performing mathematical calculations with integers and floating-point numbers is easy in Python.  Rounding Numerical Values: Problem: You want to round a floating-point number to a fixed number of decimal places. Solution: For simple rounding, use the built-in round(value, ndigits) function.   When a value is exactly halfway between two choices, the behavior of round is to round to the nearest even digit. That is the values such as 1.5 or 2.5 both get rounded to 2.   The number of digits given to round() can be negative, in which case rounding takes a place for tens, hundreds, thousands, and so on.    For example :   a = 1627731   print( round(a, -1))   print(round(a, -2))   print(round(a, -3))   Output:   1627730   1627700   1628000   Don’t confuse rounding with formatting a value for output. If your goal is simply to output a numerical value with a certain number of decimal places, you don’t typically need to u...

Web Scraping using BeautifulSoup library.

Image
  What is it a Beautifulsoup library? Beautiful Soup  is a Python library for pulling data out of HTML and XML files. It works with your favorite parser to provide idiomatic ways of navigating, searching, and modifying the parse tree. To install Beautifulsoup: pip install bs4 What is the requests library? The  library is the de facto standard for making HTTP requests in Python. It abstracts the complexities of making requests behind a beautiful, simple API so that you can focus on interacting with services and consuming data in your application. To install requests: pip install requests What is the html5lib library? html5lib is a pure python library for parsing HTML. It is designed to conform to the WHATWG HTML specification, as is implemented by all major web browsers.    To install html5lib: pip install html5lib Steps: Installing the required third-party libraries. Accessing the HTML content from the webpage. Parsing the HTML content. Searching and navig...

Web scrapping/web data extraction from website using python.

Image
Scrapping table data from website Web Scrapping: Web scrapping is technique to fetch data from websites. It is known as web data extraction.   We can do web scrapping using many ways. There are many ways to get web table data using urllib and BeautifulSoup, but its lengthy, complex and also time-consuming process.   To avoid these disadvantages, we use the pandas library. We can do same task using pandas library.                   read_html(): read_html() is the method in pandas library is a web scraping tool that extracts all the tables on a website by just giving the required URL as a parameter. Read HTML tables into a list of data frame objects.             Syntax: pandas.read_html(url, other parameters)                    Important  Parameters: match: This parameter is used for extracting the targeting table.   ...