def login(self): session = self.http_settings.session proxy = self.http_settings.proxy go_to_vporn = session.get('http://www.vporn.com', proxies=proxy) post = { "username": self.username, "password": self.password, "backto": "http://www.vporn.com" } attempt_login = session.post('http://www.vporn.com/login', data=post, proxies=proxy) doc = self.etree.fromstring(attempt_login.content, self.parser) find_profile_element = doc.xpath( '//a[@href="/profile" and @style="display: inline;"]') if find_profile_element: return True else: get_error_msg = doc.xpath('//div[@style="color: red;"]') if get_error_msg: if get_error_msg[0].text == 'Invalid username or password': raise InvalidLogin('Wrong username or password') else: raise AccountProblem('Unknown problem while login into' \ 'Vporn message:{msg}'.format(msg=get_error_msg[0].text)) raise AccountProblem('Unknown problem while login into Vporn')
def login(self): attempt_login = self._login( extra_post_vars={ "loginPage": 1, "redirectTo": "", "remember_me": "on" if self.remember_me else "off", "submit_login": "******" }, ajax=True, before_post_url='http://www.pornhub.com/login', before_post_url_vars={ "login_key": None, "login_hash": None }, post_url='http://www.pornhub.com/front/login_json') response = attempt_login.json() if int(response['success']) == 1: return True else: if response['message'] == 'Invalid username/password!': raise InvalidLogin('Wrong username or password') else: raise AccountProblem( 'Unknown problem while login into Pornhub message:{m}'. format(m=response['message'])) raise AccountProblem('Unknown problem while login into Pornhub')
def login(self): attempt_login = self._login( username='******', password='******', extra_post_vars={ "iFriendID": 0, "iObjectID": 0, "iObjectType": 0, "bRemember": "2" if self.remember_me else "1", "do": "Log in" }, ajax=True, post_url='http://www.redtube.com/htmllogin') is_success = re.findall(r'parent.loginSuccess\((.*?)\);', attempt_login.content, re.I | re.M) if is_success: try: response = json.loads(is_success[0]) except: raise AccountProblem('Could not read json login response') if response['success']: return True else: doc = self.etree.fromstring(attempt_login.content, self.parser) find_errors = doc.xpath('//p[@class="error-summary"]/text()') if find_errors: if find_errors[ 0] == 'Username or password incorrect. Please try again.': raise InvalidLogin('Wrong username or password') raise AccountProblem( 'Unknown error while trying to loging into redtube.com')
def verify_account(http_settings, imap_server, username, password, ssl=True): from lxml import etree from lxml.etree import HTMLParser, tostring clicked_link = _Account.verify_account_in_html_email( http_settings, imap_server, username, password, sender='pornhub.com', clues=('text', 'Activate Your Account'), match_substring=True, ssl=True) doc = etree.fromstring(clicked_link, HTMLParser()) found_success_msg = doc.xpath('//div[@class="success"]') if found_success_msg: return True else: error_msg = doc.xpath('//div[@class="error"]//div') if error_msg: raise AccountProblem('Failed verifying pornhub account ' \ 'due to:{e}'.format( e=error_msg[0].text[2:len(error_msg[0].text)-1])) raise AccountProblem( 'Failed verifying pornhub account due to unknown error')
def login(self): attempt_login = self._login( ajax=True, post_url='http://www.tube8.com/ajax2/login/') result = attempt_login.json() if int(result['statusCode']) == 1: return True else: if result['message'] == 'Invalid login credentials': raise InvalidLogin('Wrong username or password') raise AccountProblem( 'Unknown problem while login into tube8 message:{m}'.format( m=result['message'])) raise AccountProblem('Unknown problem while login into tube8')
def login(self): session = self.http_settings.session proxy = self.http_settings.proxy go_to_xhamster = session.get('http://www.xhamster.com', proxies=proxy) timestamp = generate_timestamp() get_stats = generate_stats() stats = "{res1}:{res2}".format(res1=get_stats[0], res2=get_stats[1]) xsid = create_cookie('xsid', stats) session.cookies._cookies['.xhamster.com']['/']['xsid'] = xsid url="http://xhamster.com/ajax/login.php?act=login&ref=" \ "http%3A%2F%2Fxhamster.com%2F&stats={stats}&username={username}" \ "&password={password}&remember={remember}&_={timestamp}".format(stats=stats, username=self.username, password=self.password, remember="on" if self.remember_me else "off", timestamp=timestamp) session.headers.update({ "X-Requested-With": "XMLHttpRequest", "Accept": "Accept:text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01", "Referer": "http://xhamster.com/login.php" }) attempt_login = session.get(url, proxies=proxy) if 'login.stats' in attempt_login.content: return True else: raise AccountProblem('Unknown problem while login into xhamster')
def login(self): attempt_login = self._login( username="******", use_password=False, extra_post_vars={ "ahd_password": base64.b64encode(self.password), "Submit": "Login", "rememberme": "on" if self.remember_me else "off" }, ajax=True, post_url='http://www.youjizz.com/login_auth.php') doc = self.etree.fromstring(attempt_login.content, self.parser) if doc.xpath('//a[@href="/logout.php"]'): return True else: find_error_p = doc.xpath('//p') if find_error_p: for p in find_error_p: if p.text.strip( ) == 'The login information you have provided was incorrect. Please try again.': raise InvalidLogin('Wrong username or password') raise AccountProblem('Unknown problem while login into YouJizz')
def _find_login_errors(self, response, **kwargs): error_msg_xpath = kwargs.get('error_msg_xpath', ERROR_MESSAGES_XPATH) wrong_pass_msg = kwargs.get('wrong_pass_msg', WRONG_PASSWORD_MESSAGES) doc = self.etree.fromstring(response.content, self.parser) if not isinstance(error_msg_xpath, (list, tuple)): error_msg_xpath = [error_msg_xpath] if not isinstance(wrong_pass_msg, (list, tuple)): wrong_pass_msg = [wrong_pass_msg] for xpath in error_msg_xpath: xpath_error = doc.xpath(xpath) if xpath_error: error_msg = xpath_error[0] has_wrong_pass = self._is_wrong_password( error=error_msg, look_in_these=wrong_pass_msg) if has_wrong_pass: raise InvalidLogin('Wrong username(email) or password') raise AccountProblem('Error:{error} ' ' while login into {site}' ' username:{username} ' ' password:{password} ' ' email:{email}'.format( error=error_msg, site=self.SITE, username=self.username, password=self.password, email=self.email))
def login(self): attempt_login = self._login( extra_post_vars={"remember_me": "1" if self.remember_me else "0"}, ajax=True, post_url='http://www.hardsextube.com/login') result = attempt_login.json() if result['success']: return True else: if result['errorMessage'] == 'Username or password is incorrect': raise InvalidLogin('Wrong username or password') else: raise AccountProblem('Unknown problem while login into' \ 'Hardsextube message:{msg}'.format(msg=result['errorMessage'])) raise AccountProblem('Unknown problem while login into Hardsextube')
def login(self): attempt_login = self._login(extra_post_vars={ "login_remember": "1" if self.remember_me else "0", "submit_login": "******" }, ajax=True, post_url='http://www.nuvid.com/ajax/login') result = attempt_login.json() if result['success']: return True else: if result['error'] == 'Invalid username and/or password!': raise InvalidLogin('Wrong username or password') else: raise AccountProblem('Unknown problem while login into' \ 'Nuvid message:{msg}'.format(msg=result['error'])) raise AccountProblem('Unknown problem while login into Nuvid')
def login(self): attempt_login = self._login(username='******', password='******', extra_post_vars={"_target_path":"/"}, ajax=True, before_post_url='http://www.f*x.com/login', post_url='http://www.f*x.com/login_check') response = attempt_login.json() if response['result'] == 'ok': return True raise AccountProblem('Something went wrong while login into 4tube.com')
def login(self): session = self.http_settings.session proxy = self.http_settings.proxy go_to_spankwire = session.get('http://www.spankwire.com', proxies=proxy) doc = self.etree.fromstring(go_to_spankwire.content, self.parser) get_js_scripts = doc.xpath('//script[@type="text/javascript"]') login_url = None if get_js_scripts: for js in get_js_scripts: if js.text: find_link = re.findall(r'jsUrlList.push\("(.*?)"\);', js.text, re.I | re.M) if find_link: if 'SpankWire2' in find_link[0]: login_url = find_link[0] break if login_url is None: raise ParsingProblem('Could not find spanwire post url to login') post = {"Password": str(self.password), "UserName": str(self.username)} session.headers.update({ "X-AjaxPro-Method": "Authenticate2", "Origin": "http://www.spankwire.com", "Referer": "http://www.spankwire.com/" }) login_url = 'http://www.spankwire.com/ajaxpro/{url}'.format( url=login_url.split('/ajaxpro/')[1]) attempt_login = session.post(login_url, data=json.dumps(post), proxies=proxy) result = attempt_login.json() if 'value' in result: if result['value']['LoginSuccess']: return True else: if result['value']['Reason'] == 'Bad Username or Password': raise InvalidLogin('Wrong username(email) or password') raise AccountProblem( 'Unknown problem while login into Spankwire message:{e}'. format(e=result['value']['Reason']))
def login(self): attempt_login = self._login( extra_headers={ "Accept": "application/json, text/javascript, */*; q=0.01" }, ajax=True, post_url='http://www.keezmovies.com/ajax/login') response = attempt_login.json() if response['response']['success']: return True else: raise AccountProblem('Unknown problem while login into KeezMovies')
def login(self): attempt_login = self._login( username='******', password='******', extra_post_vars={"_target_path": "/"}, ajax=True, before_post_url='http://www.porntube.com/login', post_url='http://www.porntube.com/login_check') check_logined = self.is_logined() if check_logined: return True else: raise AccountProblem('Unknown problem while login into PornTube')
def login(self): attempt_login = self._login(extra_post_vars={"remember_me":"on" if self.remember_me else "off", "next":"/my_profile.php"}, post_url='https://www.tnaflix.com/getiton.php') if attempt_login.url == 'https://www.tnaflix.com/my_profile.php': return True else: doc = self.etree.fromstring(attempt_login.content,self.parser) get_error_msg = doc.xpath('//div[@class="notificationBlock notifErrorBlock"]//text()') if get_error_msg: error_msg = "".join([txt for txt in get_error_msg]) if 'Invalid Username/Password or your account is not verified yet.' in error_msg: raise InvalidLogin('Wrong username or password, or account is not verified') raise AccountProblem('Unknown problem while login into Tnaflix')
def login(self): attempt_login = self._login( extra_post_vars={ 'submit_login': '******', 'login_remember': 'true' if self.remember_me else 'false' }, ajax=True, before_post_url= 'http://www.drtuber.com/ajax/popup_forms?form=login', post_url='http://www.drtuber.com/ajax/login') result = attempt_login.json() if result['success']: return True else: if result['error'] == 'Invalid username and/or password!': raise InvalidLogin('Wrong username or password') raise AccountProblem( 'Unknown problem while login into DrTuber message:{e}'.format( e=result['error']))
def verify_account(http_settings, imap_server, username, password, ssl=True): clicked_link = _Account.verify_account_in_plain_email( http_settings, imap_server, username, password, sender='xvideos.com', regexes=(r'this\s+URL:\s+(.*?).\s+', 1), ssl=True) doc = etree.fromstring(clicked_link, HTMLParser()) found_success_msg = doc.xpath('//p[@class="inlineOK"]') if found_success_msg: p = found_success_msg[0].text if p == 'Your email is now validated.': return True else: raise AccountProblem('Failed xvideos account due to unknown error')
def create(cls, username, password, email, gender, name, first_name, birthdate, country, region, city, **kwargs): def get_recaptcha_key(html): doc = etree.fromstring(html, HTMLParser()) found_captcha_key = doc.xpath('//div[@id="signupCaptcha"]/script') if not found_captcha_key: raise CannotFindVar( 'Cannot find recaptcha key for xvideos.com') return found_captcha_key[0].attrib['src'].replace( 'http://www.google.com/recaptcha/api/challenge?k=', '') def get_sign_up_errors(html): errors = [] doc = etree.fromstring(html, HTMLParser()) for possible_error in doc.xpath('//*[@class="inlineError"]'): if possible_error.text: errors.append(possible_error.text) return errors if gender.lower() == 'm': gender = 'Man' if gender.lower() == 'f': gender = 'Woman' if len(birthdate.split('/')) != 3: raise AccountProblem('Birthday does not match mm/dd/yyyy format') birth_day = birthdate.split('/')[0] birth_month = birthdate.split('/')[1] birth_year = birthdate.split('/')[2] http_settings = kwargs.get('http_settings', HttpSettings()) session = kwargs.get('session', http_settings.session) proxy = kwargs.get('proxy', http_settings.proxy) captcha_solver = kwargs.get('captcha_solver', DEFAULT_CAPTCHA_SOLVER) maximum_waiting_time = kwargs.get('maximum_waiting_time', DEFAULT_CAPTCHA_MAXIMUM_WAITING) remember_me = kwargs.get('remember_me', False) session.get('http://www.xvideos.com', proxies=proxy) create_page = session.get('http://upload.xvideos.com/account/create', proxies=proxy) recaptcha_key = get_recaptcha_key(html=create_page.content) recaptcha_challenge = get_new_recaptcha_challenge(key=recaptcha_key) captcha_image = get_recaptcha_image(challenge=recaptcha_challenge) captcha_response = cls.submit_captcha_and_wait( captcha_image, captcha_solver=captcha_solver, maximum_waiting_time=maximum_waiting_time) post = { 'referer': '', 'recaptcha_challenge_field': recaptcha_challenge, 'recaptcha_response_field': captcha_response, 'creer': '1', 'email': email, 'profile_name': username, 'password': password, 'password_confirm': password, 'nom': name, 'prenom': first_name, 'birth_year': birth_year, 'birth_month': birth_month, 'birth_day': birth_day, 'sexe': gender, 'pays': country, 'region': region, 'ville': city } create_account = session.post( 'http://upload.xvideos.com/account/create', data=post, proxies=proxy) sign_up_errors = get_sign_up_errors(html=create_account.content) if sign_up_errors: raise AccountProblem('Failed creating xvideos.com ' 'account due to errors:{e}'.format( e=' AND '.join(sign_up_errors))) return cls(username=username, password=password, email=email, gender=gender, name=name, first_name=first_name, birthdate=birthdate, country=country, region=region, city=city, remember_me=remember_me)
def create(cls, username, password, email, **kwargs): from lxml import etree from lxml.etree import HTMLParser from bringyourownproxies.httpclient import HttpSettings from bringyourownproxies.errors import CannotFindVar remember_me = kwargs.get('remember_me', False) http_settings = kwargs.get('http_settings', HttpSettings()) session = http_settings.session proxy = http_settings.proxy session.get('http://www.pornhub.com', proxies=proxy) create_page = session.get('http://www.pornhub.com/create_account', proxies=proxy) doc = etree.fromstring(create_page.content, HTMLParser()) found_signup_key = doc.xpath('//input[@name="signup_key"]/@value') found_signup_hash = doc.xpath('//input[@name="signup_hash"]/@value') found_signup_id = doc.xpath('//input[@name="signup_id"]/@value') if not found_signup_key: raise CannotFindVar('Cannot find signup_key in pornhub.com') if not found_signup_hash: raise CannotFindVar('Cannot find signup_hash in pornhub.com') if not found_signup_id: raise CannotFindVar('Cannot find signup_id in pornhub.com') signup_key = found_signup_key[0] signup_hash = found_signup_hash[0] signup_id = found_signup_id[0] post = { 'signup_key': signup_key, 'signup_hash': signup_hash, 'signup_id': signup_id, 'check_what': 'username', 'email': email, 'username': username, 'password': password, 'agreed': '1' } session.headers.update({'X-Requested-With': 'XMLHttpRequest'}) session.post('http://www.pornhub.com/user/create_account_check', proxies=proxy) create_account = session.post('http://www.pornhub.com/create_account', data=post, proxies=proxy) errors = [] doc = etree.fromstring(create_account.content, HTMLParser()) found_errors = doc.xpath('//div[@class="error"]/div') if found_errors: errors = [ error.text[2:len(error.text) - 1] for error in found_errors ] raise AccountProblem( 'Failed creating account at pornhub due to errors:{e}'.format( e=' AND '.join(errors))) found_confirmation = doc.xpath( '//div[@class="sprite-signup-confirmation absolute"]') if found_confirmation: return True else: raise AccountProblem( 'Failed creating account at pornhub for unknown problem')
def verify_account_in_plain_email(http_settings, imap_server, username, password, sender, regexes, ssl=True): import re from imbox import Imbox from bringyourownproxies.errors import VerificationLinkNotFound, AccountProblem email_box = Imbox(imap_server, username, password, ssl) msgs = email_box.messages(sent_from=sender) verification_link = None if isinstance(regexes, (list, tuple)): if not isinstance(regexes[0], (list, tuple)): if len(regexes) != 2: raise AccountProblem( 'regexes needs to be a list/tuple each containing 2 tuple/list items' \ ' one item is the regex the other is the group num when found') else: regexes = [regexes] else: for regex in regexes: if isinstance(regex, (list, tuple)): if len(regex) != 2: raise AccountProblem( 'regexes needs to be a list/tuple each containing 2 tuple/list items' \ ' one item is the regex the other is the group num when found') else: raise AccountProblem( 'regexes needs to be a list/tuple each containing 2 tuple/list items' \ ' one item is the regex the other is the group num when found') else: raise AccountProblem( 'regexes needs to be a list/tuple each containing 2 tuple/list items' \ ' one item is the regex the other is the group num when found') for msg in msgs: uid, email = msg content = email.body['plain'][0] for regex_config in regexes: regex, group_num = regex_config found = re.search(regex, content) if found: verification_link = found.group(group_num) break if verification_link: break if not verification_link: raise VerificationLinkNotFound('Could not find verification' \ 'link from sender:{sender}'.format(sender=sender)) session = http_settings.session proxy = http_settings.proxy verify = session.get(verification_link, proxies=proxy) return verify.content
def create(cls, username, password, email, gender, **kwargs): def get_captcha_image(): download_captcha = session.get('http://www.drtuber.com/captcha', proxies=proxy) captcha_data = io.BytesIO(download_captcha.content) return captcha_data if gender.lower() == 'm': gender = 'Male' if gender.lower() == 'f': gender = 'Female' http_settings = kwargs.get('http_settings', HttpSettings()) session = kwargs.get('session', http_settings.session) proxy = kwargs.get('proxy', http_settings.proxy) captcha_solver = kwargs.get('captcha_solver', DEFAULT_CAPTCHA_SOLVER) maximum_waiting_time = kwargs.get('maximum_waiting_time', DEFAULT_CAPTCHA_MAXIMUM_WAITING) url = 'http://www.drtuber.com/ajax/popup_forms?form=signup' sign_up_form = session.get(url, proxies=proxy) doc = etree.fromstring(sign_up_form.json()['answer'], HTMLParser()) found_form_id = doc.xpath('//input[@name="formId"]/@value') if not found_form_id: raise CannotFindVar( 'Cannot find formId , required for creating an account') form_id = found_form_id[0] captcha_image = get_captcha_image() captcha_response = cls.submit_captcha_and_wait( captcha_image, maximum_waiting_time=maximum_waiting_time, captcha_solver=captcha_solver) url = 'http://www.drtuber.com/signup/do?ajax=true&json=true' post = { 'username': username, 'password': password, 'password_confirm': password, 'gender': gender, 'email': email, 'verification': captcha_response, 'terms': 'on', 'age': 'on', 'formId': form_id, 'type': 'free', 'redirectUrl': '/', 'from': '' } create_account = session.post(url, data=post, proxies=proxy) response = create_account.json() if response['errors']: raise AccountProblem('Cannot create drtuber account due to errors:' \ '{e}'.format(e=" AND ".join(response['errors']))) remember_me = kwargs.get('remember_me', False) return cls(username=username, password=password, email=email, remember_me=remember_me, gender=gender)
def verify_account_in_html_email(http_settings, imap_server, username, password, sender, clues, match_substring=False, ssl=True): from bringyourownproxies.errors import VerificationLinkNotFound, AccountProblem email_box = Imbox(imap_server, username, password, ssl) msgs = email_box.messages(sent_from=sender) verification_link = None if isinstance(clues, (list, tuple)): if not isinstance(clues[0], (list, tuple)): if len(clues) != 2: raise AccountProblem( 'clues needs to be a list/tuple each containing 2 tuple/list items' ) else: clues = [clues] else: for clue in clues: if isinstance(clue, (list, tuple)): if len(clue) != 2: raise AccountProblem( 'clues needs to be a list/tuple each containing 2 tuple/list items' ) else: raise AccountProblem( 'clues needs to be a list/tuple each containing 2 tuple/list items' ) else: raise AccountProblem( 'clues needs to be a list/tuple each containing 2 tuple/list items' ) for msg in msgs: uid, email = msg doc = etree.fromstring(email.body['html'][0], HTMLParser()) for a in doc.xpath('//a'): for clue in clues: clue_attrib, clue_value = clue if clue_attrib == 'text': value_found = a.text else: value_found = a.attrib[clue_attrib] if match_substring: if value_found: if clue_value in value_found: verification_link = a.attrib['href'] break if clue_value == value_found: verification_link = a.attrib['href'] break if not verification_link: raise VerificationLinkNotFound( 'Cannot find email verification link sent from:{sender}'. format(sender=sender)) session = http_settings.session proxy = http_settings.proxy verify = session.get(verification_link, proxies=proxy) return verify.content