Ejemplo n.º 1
0
def request_auth():
    """TODO Make real request """
    api = LinkedIn(KEY, SECRET, RETURN_URL)
    api.request_token()
    print api._request_token

    print api._request_token_secret
    url = api.get_authorize_url()
    print url

    #oauth_token = bf688755-dd92-4792-ab8f-ffd7085c7e40
    # oauth_verifier=27219

    # Flow to get approved:
    # api = linkedin.LinkedIn(KEY, SECRET, RETURN_URL)
    # api.requestToken()
    # api.request_token
    # > '829861f4-2723-4fe4-9e36-c77564ec0a93'
    # api.request_token_secret
    # > 'b8b5aa3b-731b-43dd-ab44-3cffc857ad1f'
    # api.getAuthorizeURL()
    # > https://api.linkedin.com/uas/oauth/authorize?oauth_token=829861f4-2723-4fe4-9e36-c77564ec0a93
    # <paste in browser will return link like: http://localhost/?oauth_token=829861f4-2723-4fe4-9e36-c77564ec0a93&oauth_verifier=48662
    # 
    # api.accessToken(verifier = '48662')
    # > True (hopefully!)
    #  api.access_token
    # '4a1db6ff-999d-483c-8b20-779bed512d0f'
Ejemplo n.º 2
0
def __conect_to_linkedin():
    li = LinkedIn(__API_KEY, __SECRET_KEY)
    token = li.getRequestToken(None)
    # prompt user in the web browser to login to LinkedIn and then enter a code that LinkedIn gives to the user
    auth_url = li.getAuthorizeUrl(token)
    webbrowser.open(auth_url)
    validator = input("Enter token: ")
    access_token = li.getAccessToken(token, validator)
    return li, access_token
Ejemplo n.º 3
0
def __conect_to_linkedin():
    li = LinkedIn(__API_KEY, __SECRET_KEY)
    token = li.getRequestToken(None)
    # prompt user in the web browser to login to LinkedIn and then enter a code that LinkedIn gives to the user
    auth_url = li.getAuthorizeUrl(token)
    webbrowser.open(auth_url)
    validator = input("Enter token: ")
    access_token = li.getAccessToken(token, validator)
    return li, access_token
Ejemplo n.º 4
0
def new_user():
    content = request.json
    logging.info("[new_user] got request with content %s" % str(content))
    id = content.get('id', '')
    auth_code = content.get('auth_code', '')
    name = content.get('name', '')
    phone_number = content.get('phone_number', '')
    if not all([id, auth_code, name, phone_number]):
        logging.info("[new_user] missing name, auth_code, id, or phone_number")
        return error_code(400, "Must passed id, name, auth_code, phone_number")
    li = LinkedIn()
    access_token = "foo"  # li.getAccessToken(auth_code)
    db = get_database()
    doc_ref = db.collection(id).document("metadata")
    data = {'name': name, 'access_token': access_token, 'phone_number': phone_number}
    resp = new_doc(doc_ref, data)
    if resp.status_code == 200:
        doc_ref = db.collection("collections").document("metadata")
        doc_ref.update({'names': firestore.ArrayUnion([id])})
    return resp
Ejemplo n.º 5
0
def read_options(argn, argc, argv):
    try:
        opts, args = getopt.getopt(argv,"hvrc:p:l:w:o:q:",["help", "verbose", "remove", "listcountries", "country=", "platform=", "login="******"passoword=", "out=", "query=", "in"])
    except getopt.GetoptError as e:
        print_wrong_arguments(argn, e)
        sys.exit(2)

    optind = 0
    for opt, arg in opts:
        if opt in ("-h", "--help"):
            print_help(argn, arg)
            sys.exit(0)
        elif opt == "--listcountries":
            print "\n".join(linkedin.countriesNameCode())
            sys.exit(0)
        elif opt in ("-v", "--verbose"):
            global verbose
            verbose = True
        elif opt in ("-r", "--remove"):
            remove_file("parser.cookies.txt")
        elif opt in ("-c", "--country"):
            global linkedin_country
            linkedin_country = arg
        elif opt in ("-o", "--out"):
            global output_file_name
            output_file_name = arg
        elif opt in ("-p", "--platform"):
            global platform
            if arg in platforms:
                platform = arg
            else:
                print("Platform \"%s\" not supported default \"%s\" will be used" % (arg, platform))
        elif opt in ("-l", "--login"):
            global login
            login = arg
        elif opt in ("-w", "--password"):
            global password
            password = arg
        elif opt == "--in":
            global query
            query = sys.stdin.readline().rstrip('\n')
        elif opt in ("-q", "--query"):
            query = arg
        optind = optind + 1 + (0 if arg == "" else 1)

    while optind < argc :
        if argv[optind] in ["-"] :
            query = sys.stdin.readline().rstrip('\n')
        elif query == None :
            query = argv[optind]
        optind = optind+1

    if verbose == True:
        print_values()

    #Main Action
    fetch = None
    if platform == 'linkdin':
        if login != None and password != None:
            fetch = LinkedIn(query, linkedin_country, verbose=verbose, login=login, password=password)
        else:
            fetch = LinkedIn(query, linkedin_country, verbose=verbose)
    elif x == 'showmeboone':
        fetch = ShowMeBoone()
    else:
        print("Upsssss, update needed")

    if verbose == True:
        print "Object Type - %s" % fetch

    # Fetch result
    fetch.csv(output_file_name)
Ejemplo n.º 6
0
        recordpos = recordpos + 1


input_file = raw_input("Enter input file path\n")
outfile = raw_input("Enter filename for output (exclude file extension)\n")
print "[Info] Reading Customer Data"
analysis_reader = csv.reader(open(input_file, 'rU'), delimiter=",")

rows = []

for line in analysis_reader:
    rows.append(line)

records = []
profiles = []
linkedin = LinkedIn()

for i in range(100):
    #Pass the customer name and get search results
    row = rows[i]
    # print row
    if (row[1] != 'cst_type' and row[5] != 'NULL' and row[1] == 'Individual'):
        print "[Info] Searching %s" % row[5].split(",")[0]
        print
        try:
            # Search in linkedin with customer name
            search_results = linkedin.search(row[5].split(",")[0])

            # If there are many records even after filtering based on city, skipping that for now. Should implement a new method to filter results.
            if (len(search_results) == 1):
                print search_results[0]['url']
Ejemplo n.º 7
0
    def __init__(self):
        self.linkedin = LinkedIn(proxies=self.__PROXIES)

        self.crawler = Crawler(linkedin=self.linkedin)
        self.scraper = Scraper(linkedin=self.linkedin)
Ejemplo n.º 8
0
def mgc_handle():
    """Get API handle for Mike's account using hs_hackday app"""
    api = LinkedIn(KEY, SECRET, RETURN_URL)
    api._access_token = '4a1db6ff-999d-483c-8b20-779bed512d0f'
    api._access_token_secret = '6729077d-6861-456a-9782-5b5e46ce7733'
    return api
Ejemplo n.º 9
0
from linkedin import LinkedIn
email = "*****@*****.**"  #set username
password = "******"  #set password
target_profile = "https://www.linkedin.com/in/tufayel-ahmed-cse/"  #set target profile url
client = LinkedIn()
if client.login(email, password):

    #for single profile
    print(client.singleScan(target_profile))

    #for bulk list
    #profiles = ["PROFILE_URL_1","PROFILE_URL_2"]
    #print(client.bulkScan(target_profile))
else:
    print("Login Failed, please recheck login credentials")
Ejemplo n.º 10
0
 def __init__(self):
     self._linkedin = OldLinkedIn(None, None, None, False)
Ejemplo n.º 11
0
class LinkedIn(object):
    
    def __init__(self):
        self._linkedin = OldLinkedIn(None, None, None, False)
    
    def api_key(self, api_key):
        self._linkedin._api_key = api_key
        return self
        
    def secret_key(self, api_secret):
        self._linkedin._api_secret = api_secret
        return self
        
    def callback_url(self, callback_url):
        self._linkedin._callback_url = callback_url
        return self
    
    def gae(self):
        self._linkedin._gae = True
        return self
        
    def nogae(self):
        self._linkedin._gae = False
        return self
        
    def reset(self):
        self._linkedin.clear()
        return self
    

    def _check_basic_parameters(self):
        if not self._linkedin._api_key:
            raise ConfigurationError("Please run api_key() first")
        if not self._linkedin._api_secret:
            raise ConfigurationError("Please run secret_key() first")
        if not self._linkedin._callback_url:
            raise ConfigurationError("Please run callback_url() first")

    def request_token(self):
        self._check_basic_parameters()
        
        if self._linkedin._request_token or self._linkedin._access_token or \
            self._linkedin._verifier or self._linkedin._request_token_secret or \
            self._linkedin._access_token_secret:
            raise ConfigurationError("Please run reset() before running request_token again")
        
        self._linkedin.request_token()
        return self
    
    def get_authorize_url(self):
        if not (self._linkedin._request_token):
            raise ConfigurationError("Please run request_token() before running get_authorize_url()")
        return self._linkedin.get_authorize_url()
        
    def verifier(self, verifier):
        self._linkedin._verifier = verifier
        return self
    
    def access_token(self):
        if not (self._linkedin._request_token and self._linkedin._request_token_secret):
            raise ConfigurationError("Please run request_token() before running access_token()")
        
        if not self._linkedin._verifier:
            raise ConfigurationError("Please run verifier() before running access_token()")
        
        if self._linkedin._access_token or self._linkedin._access_token_secret:
            raise ConfigurationError("Please run reset() before running access_token again")
        
        self._linkedin.access_token()
        return self
        
    def profile(self, params = None):
        if not params:
            params = Profile()
        
        if isinstance(params, Profile):
            url = params.get_url_for_api()
        elif isinstance(params, str):
            url = params
        else:
            raise ValueError("Can't handle type {0}".format(params))
        
        return self._linkedin.get_profile_raw(url)
Ejemplo n.º 12
0
 def __init__(self):
     self._linkedin = OldLinkedIn(None, None, None, False)
Ejemplo n.º 13
0
class LinkedIn(object):
    def __init__(self):
        self._linkedin = OldLinkedIn(None, None, None, False)

    def api_key(self, api_key):
        self._linkedin._api_key = api_key
        return self

    def secret_key(self, api_secret):
        self._linkedin._api_secret = api_secret
        return self

    def callback_url(self, callback_url):
        self._linkedin._callback_url = callback_url
        return self

    def gae(self):
        self._linkedin._gae = True
        return self

    def nogae(self):
        self._linkedin._gae = False
        return self

    def reset(self):
        self._linkedin.clear()
        return self

    def _check_basic_parameters(self):
        if not self._linkedin._api_key:
            raise ConfigurationError("Please run api_key() first")
        if not self._linkedin._api_secret:
            raise ConfigurationError("Please run secret_key() first")
        if not self._linkedin._callback_url:
            raise ConfigurationError("Please run callback_url() first")

    def request_token(self):
        self._check_basic_parameters()

        if (
            self._linkedin._request_token
            or self._linkedin._access_token
            or self._linkedin._verifier
            or self._linkedin._request_token_secret
            or self._linkedin._access_token_secret
        ):
            raise ConfigurationError("Please run reset() before running request_token again")

        self._linkedin.request_token()
        return self

    def get_authorize_url(self):
        if not (self._linkedin._request_token):
            raise ConfigurationError("Please run request_token() before running get_authorize_url()")
        return self._linkedin.get_authorize_url()

    def verifier(self, verifier):
        self._linkedin._verifier = verifier
        return self

    def access_token(self):
        if not (self._linkedin._request_token and self._linkedin._request_token_secret):
            raise ConfigurationError("Please run request_token() before running access_token()")

        if not self._linkedin._verifier:
            raise ConfigurationError("Please run verifier() before running access_token()")

        if self._linkedin._access_token or self._linkedin._access_token_secret:
            raise ConfigurationError("Please run reset() before running access_token again")

        self._linkedin.access_token()
        return self

    def profile(self, params=None):
        if not params:
            params = Profile()

        if isinstance(params, Profile):
            url = params.get_url_for_api()
        elif isinstance(params, str):
            url = params
        else:
            raise ValueError("Can't handle type {0}".format(params))

        return self._linkedin.get_profile_raw(url)