diff --git a/username/username_profilepic.py b/username/username_profilepic.py index 09b1c8f0..12efdf96 100755 --- a/username/username_profilepic.py +++ b/username/username_profilepic.py @@ -23,15 +23,18 @@ def extracting(imglinks, username, prourl, tag, attribute, value, finattrib, pro res = requests.get(prourl) soup = BeautifulSoup(res.content, "lxml") img = soup.find(tag, {attribute: value}) - if profile == "ask.fm": - img[finattrib] = "http:" + img[finattrib] - imglinks.append(img[finattrib]) - path = "profile_pic/" + username + "/" + profile + ".jpg" - urllib.urlretrieve(img[finattrib], path) - else: - imglinks.append(img[finattrib]) - path = "profile_pic/" + username + "/" + profile + ".jpg" - urllib.urlretrieve(img[finattrib], path) + try: + if profile == "ask.fm": + img[finattrib] = img[finattrib] + imglinks.append(img[finattrib]) + path = "profile_pic/" + username + "/" + profile + ".jpg" + urllib.urlretrieve(img[finattrib], path) + else: + imglinks.append(img[finattrib]) + path = "profile_pic/" + username + "/" + profile + ".jpg" + urllib.urlretrieve(img[finattrib], path) + except TypeError as e: + colored(style.BOLD + '[!] Error: ' + str(e) + '.\n' + style.END, 'red') return imglinks diff --git a/username/username_twitterdetails.py b/username/username_twitterdetails.py index fc75b13e..887136cd 100755 --- a/username/username_twitterdetails.py +++ b/username/username_twitterdetails.py @@ -32,9 +32,17 @@ def twitterdetails(username): f = open("temptweets.txt", "w+") # writing tweets to temp file- last 1000 - for tweet in tweepy.Cursor(api.user_timeline, id=username).items(1000): - f.write(tweet.text.encode("utf-8")) - f.write("\n") + try: + for tweet in tweepy.Cursor(api.user_timeline, id=username).items(1000): + f.write(tweet.text.encode("utf-8")) + f.write("\n") + except tweepy.error.TweepError as e: + if '401' in e.message: + print colored(style.BOLD + + '[!] Error: API Keys are invalid or Twitter account set to private.\n' + + style.END, 'red') + else: + print colored(style.BOLD + '[!] Error: ' + str(e) + '.\n' + style.END, 'red') # extracting hashtags f = open('temptweets.txt', 'r')