Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from python_anticaptcha import AnticaptchaClient, NoCaptchaTaskProxylessTask
- import cfscrape
- import pyotp
- import time
- import requests
- import re
- WEBSITE_URL = "https://www.mc-market.org/"
- LOGIN_URL = "https://www.mc-market.org/login/login"
- TWO_STEP_URL = "https://www.mc-market.org/login/two-step"
- RESOURCES_URL = "https://www.mc-market.org/resources/market-place-dashboard/manage-licenses?order=title&direction=asc&license_status=all&user_id={}&resource_id=0&filter_by_user=1&url=resources%2Fmarket-place-dashboard%2Fmanage-licenses"
- FIND_MEMBER_URL = "https://www.mc-market.org/members/"
- CAPTCHA_VERIFY_URL = "http://mc-market.org/cdn-cgi/l/chk_captcha"
- RESOURCES_KEYS = {}
- PROFILE_URL = "https://www.mc-market.org/members/{}/"
- VERIFICATION_NEED = "Two-Step Verification Required"
- NO_LICENSE_FOUND = "No license was found"
- ERROR_MESSAGE = "The following error occurred"
- CHECKING_ACCOUNT = False
- headers = {"Connection": "keep-alive", "Host": "www.mc-market.org", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", "Upgrade-Insecure-Requests": "1", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36"}
- def handle_login(email, password, check_for_captcha=True):
- """This function handles the login for the website."""
- # Login details
- data = {"login": email, "register": "0", "password": password, "cookie_check": "1", "redirect": "%2F", "_xfToken": ""}
- # Posting the data to the login url
- respond = scraper.post(LOGIN_URL, data=data, headers=headers)
- # Checks if captcha should be solved
- if "captcha" in str(respond.content).lower():
- # Making sure we really need to solve the captcha
- # Used for disabling infinite loops when fails
- if not check_for_captcha:
- print("Tried to solve captcha once but failed...")
- return ""
- # Starting to solve captcha
- print("Solving captcha...")
- api_key = '...' # API key for the anti-captcha service
- site_key = '6LfBixYUAAAAABhdHynFUIMA_sa4s-XsJvnjtgB0' # The key from mc-market
- # Preparing captcha guess for the website
- client = AnticaptchaClient(api_key)
- task = NoCaptchaTaskProxylessTask(website_url=LOGIN_URL, website_key=site_key)
- job = client.createTask(task)
- job.join()
- # Receiving solution for recaptcha
- recaptcha_response = str(job.get_solution_response())
- # Submitting the solution to the site
- URL = str(CAPTCHA_VERIFY_URL + "?s=&id=&g-recaptcha-response=" + recaptcha_response)
- respond = scraper.get(URL, headers=headers, allow_redirects=False) # Should return the 'Set-Cookie' header
- # Trying to do the process again, without solving captcha
- return handle_login(email, password, False)
- return str(respond.content)
Add Comment
Please, Sign In to add comment