Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tinder_bot.py #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions tinder_bot.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
from selenium import webdriver
from time import sleep

from bs4 import BeautifulSoup; import itertools
from secrets import username, password

class TinderBot():
def __init__(self):
self.driver = webdriver.Chrome()


@property
def soup(self):
return BeautifulSoup(self.driver.page_source, 'lxml')

def xpath_soup(self, element):
"""
Generate xpath of soup element
:param element: bs4 text or node
:return: xpath as string
"""
components = list()
child = element if element.name else element.parent
for parent in child.parents:
"""
@type parent: bs4.element.Tag
"""
previous = itertools.islice(parent.children, 0,parent.contents.index(child))
xpath_tag = child.name
xpath_index = sum(1 for i in previous if i.name == xpath_tag) + 1
components.append(xpath_tag if xpath_index == 1 else '%s[%d]' % (xpath_tag, xpath_index))
child = parent
components.reverse()
return '/%s' % '/'.join(components)

def login(self):
self.driver.get('https://tinder.com')

Expand Down