Moved shebang to the first line to be properly interpreted

Added baseDir variable to external file paths so the script can be run outside of the working directory
This commit is contained in:
root 2020-03-03 11:26:27 -05:00
parent 9e207ebfe4
commit 8207c59e20

12
LinkedInt.py Normal file → Executable file
View file

@ -1,3 +1,5 @@
#!/usr/bin/python
# LinkedInt # LinkedInt
# Scrapes LinkedIn without using LinkedIn API # Scrapes LinkedIn without using LinkedIn API
# Original scraper by @DisK0nn3cT (https://github.com/DisK0nn3cT/linkedin-gatherer) # Original scraper by @DisK0nn3cT (https://github.com/DisK0nn3cT/linkedin-gatherer)
@ -7,9 +9,6 @@
# --- Constrain to company filters # --- Constrain to company filters
# --- Addition of Hunter for e-mail prediction # --- Addition of Hunter for e-mail prediction
#!/usr/bin/python
import sys import sys
import re import re
import time import time
@ -35,14 +34,15 @@ parser = argparse.ArgumentParser(description='Discovery LinkedIn')
parser.add_argument('-u', '--keywords', help='Keywords to search') parser.add_argument('-u', '--keywords', help='Keywords to search')
parser.add_argument('-o', '--output', help='Output file (do not include extentions)') parser.add_argument('-o', '--output', help='Output file (do not include extentions)')
args = parser.parse_args() args = parser.parse_args()
baseDir = os.path.dirname(os.path.realpath(sys.argv[0])) + os.path.sep
config = ConfigParser.RawConfigParser() config = ConfigParser.RawConfigParser()
config.read('LinkedInt.cfg') config.read(baseDir + 'LinkedInt.cfg')
api_key = config.get('API_KEYS', 'hunter') api_key = config.get('API_KEYS', 'hunter')
username = config.get('CREDS', 'linkedin_username') username = config.get('CREDS', 'linkedin_username')
password = config.get('CREDS', 'linkedin_password') password = config.get('CREDS', 'linkedin_password')
def login(): def login():
cookie_filename = "cookies.txt" cookie_filename = baseDir + "cookies.txt"
cookiejar = cookielib.MozillaCookieJar(cookie_filename) cookiejar = cookielib.MozillaCookieJar(cookie_filename)
opener = urllib2.build_opener(urllib2.HTTPRedirectHandler(),urllib2.HTTPHandler(debuglevel=0),urllib2.HTTPSHandler(debuglevel=0),urllib2.HTTPCookieProcessor(cookiejar)) opener = urllib2.build_opener(urllib2.HTTPRedirectHandler(),urllib2.HTTPHandler(debuglevel=0),urllib2.HTTPSHandler(debuglevel=0),urllib2.HTTPCookieProcessor(cookiejar))
page = loadPage(opener, "https://www.linkedin.com/") page = loadPage(opener, "https://www.linkedin.com/")
@ -300,7 +300,7 @@ def get_search():
print print
def banner(): def banner():
with open('banner.txt', 'r') as f: with open(baseDir + 'banner.txt', 'r') as f:
data = f.read() data = f.read()
print "\033[1;31m%s\033[0;0m" % data print "\033[1;31m%s\033[0;0m" % data