From ba0d236bc3a81fd2e7586ed98fd3077ae71e6206 Mon Sep 17 00:00:00 2001 From: Abdul Fatir Date: Thu, 3 Mar 2016 01:19:31 +0530 Subject: [PATCH] Fixed profile ID Fixed profile ID for users with no facebook username Of type: https://www.facebook.com/profile.php?id=xxx where xxx is the FB-ID. --- main.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 3ee18f9..07ace52 100644 --- a/main.py +++ b/main.py @@ -5,6 +5,7 @@ import sys import time import zipfile +import re from selenium import webdriver from getpass import getpass @@ -182,7 +183,18 @@ def init(): cont = True print('Loading...\n') - profile = [x for x in driver.find_elements_by_tag_name('a') if x.get_attribute('title') == 'Profile'][0].get_attribute('href').split('/')[3] + profile_url = [x for x in driver.find_elements_by_tag_name('a') if x.get_attribute('title') == 'Profile'][0].get_attribute('href') + re_search = re.search(r'(\?id=\d+)$', profile_url) + + profile = '' + if re_search: + # Profiles with no username + profile = re_search.group(0) + profile = profile.replace('?id=', '') + else: + # Profiles with username + profile = profile_url[profile_url.rfind('/')+1:] + driver.get('https://www.facebook.com/messages/'+profile) global replyButton