Exemplo n.º 1
0
def test_connection():

    # Creating a Connection
    new_instance = Database()
    cnx = new_instance.database_connector()
    cursor_variable = cnx.cursor()
    # Using the Connection
    try:
        SQL_Q = 'SELECT COUNT(*)  FROM company_list;'
        cursor_variable.execute(SQL_Q)
        row = cursor_variable.fetchall()
        print row
    except Exception as e:
        print "Exception Occured while Connecting to the Database"
        print "Error code:", e.errno  # error number
        print "SQLSTATE value:", e.sqlstate  # SQLSTATE value
        print "Error message:", e.msg  # error message
        print "Error:", e  # errno, sqlstate, msg values
Exemplo n.º 2
0
from bs4 import BeautifulSoup
import urllib2, sys
import mysql.connector
from datetime import datetime

# Database Connection Related Imports
import sys, ssl
sys.path.insert(0, sys.path[0] + '\\database')
from connection import Database
# Creating a Connection
new_instance = Database()
cnx = new_instance.database_connector()
cursor_variable = cnx.cursor()


def job_details(url):
    # print url
    header = {'User-Agent': 'Mozilla/5.0'}
    req = urllib2.Request(url, headers=header)
    # page = urllib2.urlopen(req)
    gcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
    info = urllib2.urlopen(req, context=gcontext).read()
    soup = BeautifulSoup(info, 'html.parser')
    total_data = soup.find_all("div",
                               {"class": "det-text group-effect1 arrived"})[0]
    data = total_data.find_all("a", href=True)

    mail_id = ''

    for d in data: