Guest User

Untitled

a guest
Apr 5th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. from python_anticaptcha import AnticaptchaClient, NoCaptchaTaskProxylessTask
  2. import cfscrape
  3. import pyotp
  4. import time
  5. import requests
  6. import re
  7.  
  8. WEBSITE_URL = "https://www.mc-market.org/"
  9. LOGIN_URL = "https://www.mc-market.org/login/login"
  10. TWO_STEP_URL = "https://www.mc-market.org/login/two-step"
  11. 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"
  12. FIND_MEMBER_URL = "https://www.mc-market.org/members/"
  13. CAPTCHA_VERIFY_URL = "http://mc-market.org/cdn-cgi/l/chk_captcha"
  14. RESOURCES_KEYS = {}
  15. PROFILE_URL = "https://www.mc-market.org/members/{}/"
  16.  
  17. VERIFICATION_NEED = "Two-Step Verification Required"
  18. NO_LICENSE_FOUND = "No license was found"
  19. ERROR_MESSAGE = "The following error occurred"
  20.  
  21. CHECKING_ACCOUNT = False
  22. 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"}
  23.  
  24.  
  25. def handle_login(email, password, check_for_captcha=True):
  26. """This function handles the login for the website."""
  27.  
  28. # Login details
  29. data = {"login": email, "register": "0", "password": password, "cookie_check": "1", "redirect": "%2F", "_xfToken": ""}
  30.  
  31. # Posting the data to the login url
  32. respond = scraper.post(LOGIN_URL, data=data, headers=headers)
  33.  
  34. # Checks if captcha should be solved
  35. if "captcha" in str(respond.content).lower():
  36. # Making sure we really need to solve the captcha
  37. # Used for disabling infinite loops when fails
  38. if not check_for_captcha:
  39. print("Tried to solve captcha once but failed...")
  40. return ""
  41.  
  42. # Starting to solve captcha
  43. print("Solving captcha...")
  44. api_key = '...' # API key for the anti-captcha service
  45. site_key = '6LfBixYUAAAAABhdHynFUIMA_sa4s-XsJvnjtgB0' # The key from mc-market
  46.  
  47. # Preparing captcha guess for the website
  48. client = AnticaptchaClient(api_key)
  49. task = NoCaptchaTaskProxylessTask(website_url=LOGIN_URL, website_key=site_key)
  50. job = client.createTask(task)
  51. job.join()
  52.  
  53. # Receiving solution for recaptcha
  54. recaptcha_response = str(job.get_solution_response())
  55.  
  56. # Submitting the solution to the site
  57. URL = str(CAPTCHA_VERIFY_URL + "?s=&id=&g-recaptcha-response=" + recaptcha_response)
  58. respond = scraper.get(URL, headers=headers, allow_redirects=False) # Should return the 'Set-Cookie' header
  59.  
  60. # Trying to do the process again, without solving captcha
  61. return handle_login(email, password, False)
  62.  
  63. return str(respond.content)
Add Comment
Please, Sign In to add comment