(peoplelist)
| 114 | |
| 115 | |
| 116 | def fill_facebook(peoplelist): |
| 117 | FacebookfinderObject = facebookfinder.Facebookfinder(showbrowser) |
| 118 | FacebookfinderObject.doLogin(facebook_username, facebook_password) |
| 119 | if args.waitafterlogin: |
| 120 | input("Press Enter to continue after verifying you are logged in...") |
| 121 | |
| 122 | count = 1 |
| 123 | ammount = len(peoplelist) |
| 124 | for person in peoplelist: |
| 125 | if args.vv == True or args.debug == True: |
| 126 | print("Facebook Check %i/%i : %s" % (count, ammount, person.full_name)) |
| 127 | else: |
| 128 | sys.stdout.write( |
| 129 | "\rFacebook Check %i/%i : %s " % (count, ammount, person.full_name)) |
| 130 | sys.stdout.flush() |
| 131 | count = count + 1 |
| 132 | # Testcode to mimic a session timeout |
| 133 | # if count == 3: |
| 134 | # print "triggered delete" |
| 135 | # FacebookfinderObject.testdeletecookies() |
| 136 | #print(person.person_imagelink) |
| 137 | #print(person.person_image) |
| 138 | if person.person_image: |
| 139 | try: |
| 140 | target_image = face_recognition.load_image_file(person.person_image) |
| 141 | target_encoding = face_recognition.face_encodings(target_image)[0] |
| 142 | profilelist = FacebookfinderObject.getFacebookProfiles(person.first_name, person.last_name, |
| 143 | facebook_username, facebook_password) |
| 144 | if args.debug == True: |
| 145 | print(profilelist) |
| 146 | except: |
| 147 | continue |
| 148 | else: |
| 149 | continue |
| 150 | |
| 151 | early_break = False |
| 152 | updatedlist = [] |
| 153 | # for profilelink,distance in profilelist: |
| 154 | for profilelink, profilepic, distance, cdnpicture in profilelist: |
| 155 | try: |
| 156 | os.remove("potential_target_image.jpg") |
| 157 | except: |
| 158 | pass |
| 159 | if early_break: |
| 160 | break |
| 161 | # image_link = FacebookfinderObject.getProfilePicture(profilelink) |
| 162 | image_link = profilepic |
| 163 | # print profilelink |
| 164 | # print image_link |
| 165 | # print "----" |
| 166 | cookies = FacebookfinderObject.getCookies() |
| 167 | if image_link: |
| 168 | try: |
| 169 | # Set fake user agent as Facebook blocks Python requests default user agent |
| 170 | headers = { |
| 171 | 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0.1 Safari/602.2.14'} |
| 172 | # Get target image using requests, providing Selenium cookies, and fake user agent |
| 173 | response = requests.get(image_link, cookies=cookies, headers=headers, stream=True) |
no test coverage detected