{"record":{"id":"b3a9d650eaba4112","repo":"ytdl-org/youtube-dl","slug":"udemy-asks-you-to-solve-a-captcha-login-with-brow","errorCode":null,"errorMessage":"Udemy asks you to solve a CAPTCHA. Login with browser, solve CAPTCHA, then export cookies and pass cookie file to youtube-dl with --cookies.","messagePattern":"Udemy asks you to solve a CAPTCHA\\. Login with browser, solve CAPTCHA, then export cookies and pass cookie file to youtube-dl with --cookies\\.","errorType":"exception","errorClass":"ExtractorError","httpStatus":null,"severity":"error","filePath":"youtube_dl/extractor/udemy.py","lineNumber":143,"sourceCode":"            error_data = error.get('data')\n            if error_data:\n                error_str += ' - %s' % error_data.get('formErrors')\n            raise ExtractorError(error_str, expected=True)\n\n    def _download_webpage_handle(self, *args, **kwargs):\n        headers = kwargs.get('headers', {}).copy()\n        headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36'\n        kwargs['headers'] = headers\n        ret = super(UdemyIE, self)._download_webpage_handle(\n            *args, **compat_kwargs(kwargs))\n        if not ret:\n            return ret\n        webpage, _ = ret\n        if any(p in webpage for p in (\n                '>Please verify you are a human',\n                'Access to this page has been denied because we believe you are using automation tools to browse the website',\n                '\"_pxCaptcha\"')):\n            raise ExtractorError(\n                'Udemy asks you to solve a CAPTCHA. Login with browser, '\n                'solve CAPTCHA, then export cookies and pass cookie file to '\n                'youtube-dl with --cookies.', expected=True)\n        return ret\n\n    def _download_json(self, url_or_request, *args, **kwargs):\n        headers = {\n            'X-Udemy-Snail-Case': 'true',\n            'X-Requested-With': 'XMLHttpRequest',\n        }\n        for cookie in self._downloader.cookiejar:\n            if cookie.name == 'client_id':\n                headers['X-Udemy-Client-Id'] = cookie.value\n            elif cookie.name == 'access_token':\n                headers['X-Udemy-Bearer-Token'] = cookie.value\n                headers['X-Udemy-Authorization'] = 'Bearer %s' % cookie.value\n\n        if isinstance(url_or_request, compat_urllib_request.Request):","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/udemy.py#L125-L161","documentation":"Raised by UdemyIE._download_webpage_handle when the fetched page contains PerimeterX bot-protection markers ('Please verify you are a human', the automation-tools denial text, or the _pxCaptcha field). It tells the user to solve the CAPTCHA in a browser and reuse the session cookies. Expected error.","triggerScenarios":"Any Udemy webpage download whose HTML contains one of the three PerimeterX markers — triggered by datacenter IPs, high request rates, a spoofed Chrome 72 User-Agent the site distrusts, or missing valid cookies.","commonSituations":"Batch-download scripts hammering udemy.com, running from cloud/VPN IPs, expired cookie jars, repeated login attempts.","solutions":["Log into Udemy in a normal browser, solve any CAPTCHA, export cookies, and pass --cookies udemy_cookies.txt.","Slow down: add --sleep-interval/--max-sleep-interval and limit parallelism (--limit-rate, fewer concurrent jobs).","Run from a residential IP rather than a datacenter/VPN egress.","Retry later; PerimeterX blocks are often temporary once a clean session is established."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":"def px_blocked(page: str) -> bool:\n    return any(m in page for m in ('Please verify you are a human', '_pxCaptcha', 'automation tools'))","tryCatchPattern":"try:\n    ydl.extract_info(url)\nexcept ExtractorError as e:\n    if 'CAPTCHA' in str(e):\n        pause_and_switch_to_fresh_cookies()  # solve in browser, re-export, resume\n    else:\n        raise","preventionTips":["Always pass fresh browser cookies (--cookies) for Udemy.","Throttle with --sleep-interval and run from residential IPs; PerimeterX escalates with request volume.","Solve the CAPTCHA once in a browser and reuse that session; do not retry blindly."],"tags":["captcha","udemy","bot-protection","cookies","rate-limit"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}