Posts

Python IMAP list response, listing mailboxes, mailbox status, selecting_mailbox, searching messages, search criteria, fetching messages, whole messages, uploading messages, moving and copying messages, deleting messages, delete mailbox,search with uid

#  https://github.com/sanuptpm/imap import imaplib import re import email import time import email.message from imap_conf import open_connection list_response_pattern = re.compile(r'\((?P<flags>.*?)\) "(?P<delimiter>.*)" (?P<name>.*)') # print "list_response_pattern :", list_response_pattern def parse_list_response(line):     flags, delimiter, mailbox_name = list_response_pattern.match(line).groups()     mailbox_name = mailbox_name.strip('"')     return (flags, delimiter, mailbox_name) # Listing mailboxes def listing_mailboxes():     resp, data = c.list()     # IMAP instance     print "\nIMAP4_SSL instance :", c     # First parameter of the c.list()     print '\nResponse code:', resp     # Second parameter of the c.list()     print "\nmailboxes available for an account :", data     # Get the status...

How to configure IMAP in python

import imaplib def open_connection ( verbose = False ): # Connect to the server connection = imaplib.IMAP4_SSL( ' servername ' ) # Login to our account connection.login( ' username ' , ' password ' ) return connection # if __name__ == '__main__': # c = open_connection(verbose=True) # try: # resp, data = c.list() # print "\nIMAP4_SSL instance :", c # print '\nResponse code:', resp # print "\nmailboxes available for an account :", data # finally: # c.logout()

How To Install Golang compiler on Ubuntu

Image
$ sudo curl -O https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz $ sudo tar -xvf go1.6.linux-amd64.tar.gz $ sudo mv go /usr/local $ sudo vim ~/.profile At the end of the file, add this line: export PATH=$PATH:/usr/local/go/bin $ export GOROOT=$HOME/go $ export PATH=$PATH:$GOROOT/bin $ source ~/.profile Create a new directory for your Go workspace, which is where Go will build its files. $ mkdir $HOME/work $ export GOPATH=$HOME/work $ mkdir -p work/src/github.com/user/hello $ vim work/src/github.com/user/hello/hello.go Inside your editor, paste in the content below, which uses the main Go packages, imports the formatted IO content component, and sets a new function to print 'Hello World' when run. package main import "fmt" func main() {     fmt.Printf("hello, world\n") } compile it invoking the Go command install. $ go install github.com/user/hello The file compiled, you can run it by simply referring to the file at your Go path. $ sudo $GOPATH...

How to use bluetooth speaker in ubuntu

Image
Restart the bluetooth service   sudo /etc/init.d/bluetooth restart Pair your blue-tooth  speaker again and connect it Go to sound settings. From the output device tab you should now see the blue-tooth  speaker listed along with internal speakers Choose it as the sound output device, play music with blue-tooth  speaker.

How to get href value of each a tag from the html using python Beautiful Soup

Image
import requests from bs4 import BeautifulSoup link = "http://www.flipkart.com/mobiles?otracker=hp_header_nmenu_sub_Electronics_0_Mobiles" doc = requests.get(link) soup = BeautifulSoup(doc.text, 'html.parser') main_div = soup.find(id="list-tagcloud") div2=main_div.find_all('div')[1] links = div2.find_all('a') for link in links:     print link.attrs.get('href') OUTPUT ====== /mobiles/motorola~brand/pr?sid=tyy,4io /mobiles/lenovo~brand/pr?sid=tyy,4io /mobiles/samsung~brand/pr?sid=tyy,4io /mobiles/leeco~brand/pr?sid=tyy,4io /yu-yunicorn/p/itmejeuf7egdedar?pid=MOBEJ3MF23Q9MGMH /mobiles/honor~brand/pr?sid=tyy,4io /mobiles/mi~brand/pr?sid=tyy,4io /mobiles/asus~brand/pr?sid=tyy,4io /mobiles/apple~brand/pr?sid=tyy,4io /mobiles/intex~brand/pr?sid=tyy,4io /mobiles/sony~brand/pr?sid=tyy,4io /mobiles/alcatel~brand/pr?sid=tyy,4io /mobiles/lava~brand/pr?sid=tyy,4io /gionee-store /mobiles/pr?sid=tyy,4io

How to dispaly data from html tags using python Beautiful Soup

Image
import requests from bs4 import BeautifulSoup link = "http://www.flipkart.com/mobiles?otracker=hp_header_nmenu_sub_Electronics_0_Mobiles" doc = requests.get(link) soup = BeautifulSoup(doc.text, 'html.parser') main_div = soup.find(id="list-tagcloud") div2=main_div.find_all('div')[1] for x in div2.strings:     print x OUTPUT ====== Motorola Lenovo Samsung LeEco Yunicorn Honor Mi Asus Apple Intex Sony Alcatel Lava Gionee All

Find all the URLs found within a page’s using python

Find all the URLs found within a page’s from bs4 import BeautifulSoup html_doc = """ <html><head><title>The Dormouse's story</title></head> <body> <p class="title"><b>The Dormouse's story</b></p> <p class="story">Once upon a time there were three little sisters; and their names were <a href="http://example.com/elsie" class="sister" id="link1">Elsie</a>, <a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> and <a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>; and they lived at the bottom of a well.</p> <p class="story">...</p> """ soup = BeautifulSoup(html_doc, 'html.parser') for link in soup.find_all('a'):     print link.get('href...