Source: Online social media and website

Web Scraping

Web scraping is the term for using a program to download and process content from the Web. For example, Google runs many web scraping programs to index web pages for its search engine. In this chapter, you will learn about several modules that make it easy to scrape web pages in Python.

Web browser. Comes with Python and opens a browser to a specific page.


Requests. Downloads files and web pages from the Internet.


Beautiful Soup. Parses HTML, the format that web pages are written in.


Selenium. Launches and controls a web browser. Selenium is able to fill in forms and simulate mouse clicks in this browser.



Send email using SMTP

Simple Mail Transfer Protocol (SMTP) is a protocol, which handles sending e-mail and routing e-mail between mail servers.
Python provides smtplib module, which defines an SMTP client session object that can be used to send mail to any Internet machine with an SMTP or ESMTP listener daemon.
Here is a simple syntax to create one SMTP object, which can later be used to send an e-mail
Create “sendemail” module
import smtplib

def sendemail(from_addr, to_addr_list, cc_addr_list,
              subject, message,
              login, password,
              smtpserver):
    header  = 'From: %s\n' % from_addr
    header += 'To: %s\n' % ','.join(to_addr_list)
    header += 'Cc: %s\n' % ','.join(cc_addr_list)
    header += 'Subject: %s\n\n' % subject
    message = header + message

    server = smtplib.SMTP(smtpserver)
    server.starttls()
    server.login(login,password)
    problems = server.sendmail(from_addr, to_addr_list, message)
    server.quit()
    return problems



sendemail.sendemail(from_addr    = 'vadivel.rangasamy@gmail.com',
          to_addr_list = [' xxx123@gmail.com '],
          cc_addr_list = [‘xxx123@gmail.com’],
          subject      = 'Howdy',
          message      = 'Howdy from a python function',
          login        = abc123test@gmail.com',
          password     = 'XXXXXXXX',
          smtpserver = 'smtp.gmail.com:587')