Skip to content

Commit

Permalink
Default Changelist
Browse files Browse the repository at this point in the history
  • Loading branch information
agtt committed May 26, 2019
1 parent 8aec91e commit 66f2d2d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
34 changes: 34 additions & 0 deletions db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import mysql.connector
from mysql.connector import Error


class db:
def __init__(self, host='localhost', database='linkedin', user='root', password=''):
try:
self.connection = mysql.connector.connect(host=host, database=database, user=user, password=password)
except Error as e:
print("Error while connecting to MySQL", e)

def query(self, query):
cursor = self.connection.cursor()
cursor.execute(query)
record = self.cursor.fetchall()
return record

def addprofile(self, url, data=""):
""" Add Profile to MySQL """
try:
cursor = self.connection.cursor()
sql = "INSERT INTO scrappers (url, data) VALUES (%s, %s)"
val = (url, data)
cursor.execute(sql, val)
cursor.close()
self.connection.commit()
except Exception as e:
print(str(e))
return True

def __del__(self):
if self.connection.is_connected():
# self.cursor.close()
self.connection.close()
2 changes: 1 addition & 1 deletion profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def main(params):
linkedin = LinkedinController(config=True, debug=True)
linkedin.login()
linkedin.search('resul')
linkedin.search('murat')
# profile = linkedin.profile("https://www.linkedin.com/in/agitt/")
# print(json.dumps(profile))

Expand Down
5 changes: 5 additions & 0 deletions scrapper/Mapper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from db import db
import json
db = db()

class Mapper:

def profileMapper(self, data):
Expand Down Expand Up @@ -48,4 +52,5 @@ def searchMapper(self, data):
if p['$type'] == 'com.linkedin.voyager.identity.shared.MiniProfile':
profiles.append({'firstname': p['firstName'], 'lastname': p['lastName'], 'occupation': p['occupation'],
'publicIdentifier': p['publicIdentifier'], 'trackingId': p['trackingId']})
db.addprofile(p['publicIdentifier'], '')
return profiles

0 comments on commit 66f2d2d

Please sign in to comment.