frederikme / TinderBotz

Automated Tinder bot and scraper using selenium in python.
MIT License
539 stars 145 forks source link

Still freeze :( #4

Closed S4nderr closed 3 years ago

S4nderr commented 3 years ago

Still freeezes and is not sending any messages now :(

INPUT:

'''
Created by Frederikme (TeetiFM)
'''

from tinderbotz.session import Session
from tinderbotz.helpers.constants_helper import *

import constants

if __name__ == "__main__":

    # creates instance of session
    session = Session()

    # set location (Don't need to be logged in for this)
    #session.setCustomLocation("Leuven, Belgium")

    # Will send you an email when you have a match.
    #session.setEmailNotifications(True)

    # login using your google account with a verified email!
    #session.loginUsingGoogle(email=constants.email_google, password=constants.password_google)

    # Alternatively you can login using facebook with a connected profile!
    session.loginUsingFacebook(email="sandertkruis@gmail.com", password="Facebookww#1")

    # adjust allowed distance for geomatches
    # Note: You need to be logged in for this setting
    # Note: PARAMETER IS IN KILOMETERS!
    #session.setDistanceRange(km=25)

    # set range of allowed ages
    # Note: You need to be logged in for this setting
#    session.setAgeRange(18, 55)

    # set interested in gender(s) -> options are: WOMEN, MEN, EVERYONE
#    session.setSexuality(Sexuality.WOMEN)

    # Allow profiles from all over the world to appear
#
    # spam likes, dislikes and superlikes
    # to avoid being banned:
    #   - it's best to apply a randomness in your liking by sometimes disliking.
    #   - some sleeping between two actions is recommended
    # NOTE: these recommendations apply mostly to large amounts of swiping (+100 likes)
    session.like(amount=10, ratio="72.5%", sleep=1)
    session.dislike(amount=1)

    # Getting matches takes a while, so recommended you load as much as possible from local storage
    # get new matches, with whom you haven't interacted yet
    new_matches = session.getNewMatches()
    # get already interacted with matches
    old_matches = session.getMessagedMatches()
    # get all matches (comment out new_matches and old_matches above so it doesnt load it all for no reason)
    matches = session.getAllMatches()

    # you can store the data and images of these matches now locally in data/matches
    for match in matches:
        session.storeLocal(match)

    # Pick up line with their personal name so it doesn't look spammy
    pickup_line = "Hey {}! You. Me. Pizza? Or do you not like pizza?"

    # loop through my new matches and send them the first message of the conversation
    for match in new_matches:
        # store name and chatid in variables so we can use it more simply later on
        name = match.getName()
        id = match.getChatID()

        print(name, id)

        # Format the match her/his name in your pickup line for a more personal approach.
        message = pickup_line.format(name)

        # send pick up line with their name in it to all my matches
        session.sendMessage(chatid=id, message=message)

        # send a funny gif
        #session.sendGif(chatid=id, gifname="")

        # send a funny song
    #    session.sendSong(chatid=id, songname="")

        # send my instagram or you can use alternative socials like facebook, phonenumber and snapchat
    #    session.sendSocials(chatid=id, media=Socials.INSTAGRAM, value="Teeti.fm")

        # you can also unmatch
        #session.unMatch(chatid=id)

    # let's scrape some geomatches now
    for _ in range(5):
        # get profile data (name, age, bio, images, ...)
        geomatch = session.getGeomatch()
        # store this data locally as json with reference to their respective (locally stored) images
        session.storeLocal(geomatch)
        # dislike the profile, so it will show us the next geomatch (since we got infinite amount of dislikes anyway)
        session.dislike()

OUTPUT:

        |_   _(_)_ __   __| | ___ _ __| |__   ___ | |_ ____
          | | | | '_ \ / _` |/ _ \ '__| '_ \ / _ \| __|_  /
          | | | | | | | (_| |  __/ |  | |_) | (_) | |_ / / 
          |_| |_|_| |_|\__,_|\___|_|  |_.__/ \___/ \__/___|
        ----------------------------------------------------
Made by Frederikme
Started session: 2020-11-27 14:59:07

Adding Location Guard extension ...
Getting ChromeDriver ...

[WDM] - Current google-chrome version is 87.0.4280
[WDM] - Get LATEST driver version for 87.0.4280
[WDM] - Driver [C:\Users\Sander\.wdm\drivers\chromedriver\win32\87.0.4280.20\chromedriver.exe] found in cache
User is not logged in yet.

COOKIES ACCEPTED.
COOKIES ACCEPTED.
ACCEPTED LOCATION.
DENIED NOTIFICATIONS.
ACCEPTING LOCATION: Loading took too much time! Element probably not presented, so we continue.
[>-----------------------------] 0% of the likes handled.
[======>-----------------------] 20% of the likes handled.
[=========>--------------------] 30% of the likes handled.
[============>-----------------] 40% of the likes handled.
[===============>--------------] 50% of the likes handled.
[==================>-----------] 60% of the likes handled.
[=====================>--------] 70% of the likes handled.
[========================>-----] 80% of the likes handled.
[===========================>--] 90% of the likes handled.
[==============================>] 100% of the likes handled.

[==============================>] 100% of the likes handled.

[>-----------------------------] 0% of the dislikes handled.
[==============================>] 100% of the dislikes handled.

Getting not-interacted-with, NEW MATCHES
[>-----------------------------] 0% of the new matches handled.
[>-----------------------------] 1% of the new matches handled.
[>-----------------------------] 3% of the new matches handled.
[=>----------------------------] 5% of the new matches handled.
[=>----------------------------] 6% of the new matches handled.
[==>---------------------------] 8% of the new matches handled.
[===>--------------------------] 10% of the new matches handled.
[===>--------------------------] 11% of the new matches handled.
[===>--------------------------] 13% of the new matches handled.
[====>-------------------------] 15% of the new matches handled.
[====>-------------------------] 16% of the new matches handled.
[=====>------------------------] 18% of the new matches handled.
[======>-----------------------] 20% of the new matches handled.
[======>-----------------------] 21% of the new matches handled.
[======>-----------------------] 23% of the new matches handled.
[=======>----------------------] 25% of the new matches handled.
[=======>----------------------] 26% of the new matches handled.
[========>---------------------] 28% of the new matches handled.
[=========>--------------------] 30% of the new matches handled.
[=========>--------------------] 31% of the new matches handled.
[=========>--------------------] 33% of the new matches handled.
[==========>-------------------] 35% of the new matches handled.
[==========>-------------------] 36% of the new matches handled.
[===========>------------------] 38% of the new matches handled.
[============>-----------------] 40% of the new matches handled.
[============>-----------------] 41% of the new matches handled.
[============>-----------------] 43% of the new matches handled.
[=============>----------------] 45% of the new matches handled.
[=============>----------------] 46% of the new matches handled.
[==============>---------------] 48% of the new matches handled.
[===============>--------------] 50% of the new matches handled.
[===============>--------------] 51% of the new matches handled.
[===============>--------------] 53% of the new matches handled.
[================>-------------] 55% of the new matches handled.
[================>-------------] 56% of the new matches handled.
[=================>------------] 58% of the new matches handled.
[==================>-----------] 60% of the new matches handled.
[==================>-----------] 61% of the new matches handled.
[==================>-----------] 63% of the new matches handled.
[===================>----------] 65% of the new matches handled.
[===================>----------] 66% of the new matches handled.
[====================>---------] 68% of the new matches handled.
[=====================>--------] 70% of the new matches handled.
[=====================>--------] 71% of the new matches handled.
[=====================>--------] 73% of the new matches handled.
[======================>-------] 75% of the new matches handled.
[======================>-------] 76% of the new matches handled.
[=======================>------] 78% of the new matches handled.
[========================>-----] 80% of the new matches handled.
[========================>-----] 81% of the new matches handled.
[========================>-----] 83% of the new matches handled.
[=========================>----] 85% of the new matches handled.
[=========================>----] 86% of the new matches handled.
[==========================>---] 88% of the new matches handled.
[===========================>--] 90% of the new matches handled.
[===========================>--] 91% of the new matches handled.
[===========================>--] 93% of the new matches handled.
[============================>-] 95% of the new matches handled.
[============================>-] 96% of the new matches handled.
[=============================>] 98% of the new matches handled.
[==============================>] 100% of the new matches handled.

Getting interacted-with, MESSAGED MATCHES
[>-----------------------------] 0% of the interacted-with-matches handled.
[>-----------------------------] 3% of the interacted-with-matches handled.
[=>----------------------------] 6% of the interacted-with-matches handled.
[==>---------------------------] 9% of the interacted-with-matches handled.
[===>--------------------------] 12% of the interacted-with-matches handled.
[====>-------------------------] 15% of the interacted-with-matches handled.
[=====>------------------------] 18% of the interacted-with-matches handled.
[======>-----------------------] 21% of the interacted-with-matches handled.
[=======>----------------------] 25% of the interacted-with-matches handled.
[========>---------------------] 28% of the interacted-with-matches handled.
[=========>--------------------] 31% of the interacted-with-matches handled.
[==========>-------------------] 34% of the interacted-with-matches handled.
[===========>------------------] 37% of the interacted-with-matches handled.
[============>-----------------] 40% of the interacted-with-matches handled.
[============>-----------------] 43% of the interacted-with-matches handled.
[=============>----------------] 46% of the interacted-with-matches handled.
[===============>--------------] 50% of the interacted-with-matches handled.
[===============>--------------] 53% of the interacted-with-matches handled.
[================>-------------] 56% of the interacted-with-matches handled.
[=================>------------] 59% of the interacted-with-matches handled.
[==================>-----------] 62% of the interacted-with-matches handled.
[===================>----------] 65% of the interacted-with-matches handled.
[====================>---------] 68% of the interacted-with-matches handled.
[=====================>--------] 71% of the interacted-with-matches handled.
[======================>-------] 75% of the interacted-with-matches handled.
[=======================>------] 78% of the interacted-with-matches handled.
[========================>-----] 81% of the interacted-with-matches handled.
[=========================>----] 84% of the interacted-with-matches handled.
[==========================>---] 87% of the interacted-with-matches handled.
[===========================>--] 90% of the interacted-with-matches handled.
[===========================>--] 93% of the interacted-with-matches handled.
[============================>-] 96% of the interacted-with-matches handled.
[==============================>] 100% of the interacted-with-matches handled.

Scraping matches can take a while!

Getting not-interacted-with, NEW MATCHES
[>-----------------------------] 0% of the new matches handled.
[>-----------------------------] 1% of the new matches handled.
[>-----------------------------] 3% of the new matches handled.
[=>----------------------------] 5% of the new matches handled.
[=>----------------------------] 6% of the new matches handled.
[==>---------------------------] 8% of the new matches handled.
[===>--------------------------] 10% of the new matches handled.
[===>--------------------------] 11% of the new matches handled.
[===>--------------------------] 13% of the new matches handled.
[====>-------------------------] 15% of the new matches handled.
[====>-------------------------] 16% of the new matches handled.
[=====>------------------------] 18% of the new matches handled.
[======>-----------------------] 20% of the new matches handled.
[======>-----------------------] 21% of the new matches handled.
[======>-----------------------] 23% of the new matches handled.
[=======>----------------------] 25% of the new matches handled.
[=======>----------------------] 26% of the new matches handled.
[========>---------------------] 28% of the new matches handled.
[=========>--------------------] 30% of the new matches handled.
[=========>--------------------] 31% of the new matches handled.
[=========>--------------------] 33% of the new matches handled.
[==========>-------------------] 35% of the new matches handled.
[==========>-------------------] 36% of the new matches handled.
[===========>------------------] 38% of the new matches handled.
[============>-----------------] 40% of the new matches handled.
[============>-----------------] 41% of the new matches handled.
[============>-----------------] 43% of the new matches handled.
[=============>----------------] 45% of the new matches handled.
[=============>----------------] 46% of the new matches handled.
[==============>---------------] 48% of the new matches handled.
[===============>--------------] 50% of the new matches handled.
[===============>--------------] 51% of the new matches handled.
[===============>--------------] 53% of the new matches handled.
[================>-------------] 55% of the new matches handled.
[================>-------------] 56% of the new matches handled.
[=================>------------] 58% of the new matches handled.
[==================>-----------] 60% of the new matches handled.
[==================>-----------] 61% of the new matches handled.
[==================>-----------] 63% of the new matches handled.
[===================>----------] 65% of the new matches handled.
[===================>----------] 66% of the new matches handled.
[====================>---------] 68% of the new matches handled.
[=====================>--------] 70% of the new matches handled.
[=====================>--------] 71% of the new matches handled.
[=====================>--------] 73% of the new matches handled.
[======================>-------] 75% of the new matches handled.
[======================>-------] 76% of the new matches handled.
[=======================>------] 78% of the new matches handled.
[========================>-----] 80% of the new matches handled.
[========================>-----] 81% of the new matches handled.
[========================>-----] 83% of the new matches handled.
[=========================>----] 85% of the new matches handled.
[=========================>----] 86% of the new matches handled.
[==========================>---] 88% of the new matches handled.
[===========================>--] 90% of the new matches handled.
[===========================>--] 91% of the new matches handled.
[===========================>--] 93% of the new matches handled.
[============================>-] 95% of the new matches handled.
[============================>-] 96% of the new matches handled.
[=============================>] 98% of the new matches handled.
[==============================>] 100% of the new matches handled.

Getting interacted-with, MESSAGED MATCHES
[>-----------------------------] 0% of the interacted-with-matches handled.
[>-----------------------------] 3% of the interacted-with-matches handled.
[=>----------------------------] 6% of the interacted-with-matches handled.
[==>---------------------------] 9% of the interacted-with-matches handled.
[===>--------------------------] 12% of the interacted-with-matches handled.
[====>-------------------------] 15% of the interacted-with-matches handled.
[=====>------------------------] 18% of the interacted-with-matches handled.
[======>-----------------------] 21% of the interacted-with-matches handled.
[=======>----------------------] 25% of the interacted-with-matches handled.
[========>---------------------] 28% of the interacted-with-matches handled.
[=========>--------------------] 31% of the interacted-with-matches handled.
[==========>-------------------] 34% of the interacted-with-matches handled.
[===========>------------------] 37% of the interacted-with-matches handled.
[============>-----------------] 40% of the interacted-with-matches handled.
[============>-----------------] 43% of the interacted-with-matches handled.
[=============>----------------] 46% of the interacted-with-matches handled.
[===============>--------------] 50% of the interacted-with-matches handled.
[===============>--------------] 53% of the interacted-with-matches handled.
[================>-------------] 56% of the interacted-with-matches handled.
[=================>------------] 59% of the interacted-with-matches handled.
[==================>-----------] 62% of the interacted-with-matches handled.
[===================>----------] 65% of the interacted-with-matches handled.
[====================>---------] 68% of the interacted-with-matches handled.
[=====================>--------] 71% of the interacted-with-matches handled.
[======================>-------] 75% of the interacted-with-matches handled.
[=======================>------] 78% of the interacted-with-matches handled.
[========================>-----] 81% of the interacted-with-matches handled.
[=========================>----] 84% of the interacted-with-matches handled.
[==========================>---] 87% of the interacted-with-matches handled.
[===========================>--] 90% of the interacted-with-matches handled.
[===========================>--] 93% of the interacted-with-matches handled.
[============================>-] 96% of the interacted-with-matches handled.
[==============================>] 100% of the interacted-with-matches handled.

Image saved as C:\Users\Sander\Documents\TinderBot/data/matches/images/d941d2c8f4e367782265e61b68e48613.jpg
Traceback (most recent call last):
  File "C:\Users\Sander\Documents\TinderBot\quickstart.py", line 60, in <module>
    session.storeLocal(match)
  File "C:\Users\Sander\Documents\TinderBot\tinderbotz\session.py", line 166, in storeLocal
    StorageHelper.storeMatch(match=match, directory='data/{}'.format(filename), filename=filename)
  File "C:\Users\Sander\Documents\TinderBot\tinderbotz\helpers\storage_helper.py", line 102, in storeMatch
    data = json.load(fp)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\json\__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "C:\Users\Sander\Documents\TinderBot\tinderbotz\session.py", line 79, in cleanup
    print(self.msg_box(lines=lines, title="Tinderbotz"))
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-17: character maps to <undefined>
frederikme commented 3 years ago

Hey @S4nderr,

I'm not able to reproduce the error on my side, however I think I found a solution. Basically the error isn't really about the bot, but rather about the storage and opening of json data locally. In the latest update I applied an enforcement of encoding when loading the json on line 101 in storage_helper.py I recommend deleting your current json file located at .../TinderBot/data/matches/matches.json, so it can start storing the matching locally from start again and updating your project the newest version.

Could you let me know if this solved the issue? Greetings, Fred

S4nderr commented 3 years ago

After deleting the files and update it work like a charm again ty!

S4nderr commented 3 years ago

Hate to bring this...

But it stopped again :(

Traceback (most recent call last):
  File "C:\Users\Sander\Documents\TinderBot\quickstart.py", line 94, in <module>
    geomatch = session.getGeomatch()
  File "C:\Users\Sander\Documents\TinderBot\tinderbotz\session.py", line 230, in getGeomatch
    name = helper.getName()
  File "C:\Users\Sander\Documents\TinderBot\tinderbotz\helpers\geomatch_helper.py", line 126, in getName
    return self.getName()
  File "C:\Users\Sander\Documents\TinderBot\tinderbotz\helpers\geomatch_helper.py", line 126, in getName
    return self.getName()
  File "C:\Users\Sander\Documents\TinderBot\tinderbotz\helpers\geomatch_helper.py", line 126, in getName
    return self.getName()
  [Previous line repeated 965 more times]
  File "C:\Users\Sander\Documents\TinderBot\tinderbotz\helpers\geomatch_helper.py", line 125, in getName
    self.openProfile()
  File "C:\Users\Sander\Documents\TinderBot\tinderbotz\helpers\geomatch_helper.py", line 99, in openProfile
    WebDriverWait(self.browser, self.delay).until(EC.presence_of_element_located(
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\support\wait.py", line 71, in until
    value = method(self._driver)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\support\expected_conditions.py", line 64, in __call__
    return _find_element(driver, self.locator)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\support\expected_conditions.py", line 411, in _find_element
    return driver.find_element(*by)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 976, in find_element
    return self.execute(Command.FIND_ELEMENT, {
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 319, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 374, in execute
    return self._request(command_info[0], url, body=data)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 397, in _request
    resp = self._conn.request(method, url, body=body, headers=headers)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\request.py", line 79, in request
    return self.request_encode_body(
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\request.py", line 171, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\poolmanager.py", line 336, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 426, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1347, in getresponse
    response.begin()
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 331, in begin
    self.headers = self.msg = parse_headers(self.fp)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 225, in parse_headers
    return email.parser.Parser(_class=_class).parsestr(hstring)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\email\parser.py", line 67, in parsestr
    return self.parse(StringIO(text), headersonly=headersonly)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\email\parser.py", line 56, in parse
    feedparser.feed(data)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\email\feedparser.py", line 176, in feed
    self._call_parse()
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\email\feedparser.py", line 180, in _call_parse
    self._parse()
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\email\feedparser.py", line 295, in _parsegen
    if self._cur.get_content_maintype() == 'message':
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\email\message.py", line 594, in get_content_maintype
    ctype = self.get_content_type()
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\email\message.py", line 578, in get_content_type
    value = self.get('content-type', missing)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\email\message.py", line 471, in get
    return self.policy.header_fetch_parse(k, v)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\email\_policybase.py", line 316, in header_fetch_parse
    return self._sanitize_header(name, value)
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\email\_policybase.py", line 287, in _sanitize_header
    if _has_surrogates(value):
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\email\utils.py", line 57, in _has_surrogates
    s.encode()
RecursionError: maximum recursion depth exceeded while calling a Python object
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "C:\Users\Sander\Documents\TinderBot\tinderbotz\session.py", line 79, in cleanup
    print(self.msg_box(lines=lines, title="Tinderbotz"))
  File "C:\Users\Sander\AppData\Local\Programs\Python\Python38-32\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-17: character maps to <undefined>
frederikme commented 3 years ago

Should be fixed by now. :) There was an infinite recursive function, which caused a crash. It should be working more or less flawless now (hopefully) :D