You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用edx-dl模块下载课程遇403错误及Cloudflare拦截问题求助

Fixing edx-dl HTTP 403 Forbidden (Cloudflare Block) on Windows 10

Hey there, let's tackle this Cloudflare 403 error you're hitting with edx-dl. Your hunch about the User-Agent is spot-on—Cloudflare often blocks requests that look like they're coming from automated tools instead of real browsers. Here's how to fix it step by step:

1. Test with a Custom User-Agent via Command Line

First, try overriding the default User-Agent that edx-dl uses with a modern browser's UA string. This tricks Cloudflare into thinking the request is coming from a real browser.

Run this command (you can replace the UA string with your current browser's UA—find it by searching "what's my user agent" online if you want):

edx-dl -u user@user.com --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36" COURSE_URL

If this works, you can make this setting permanent so you don't have to type it every time.

2. Set a Permanent User-Agent in edx-dl's Config File

On Windows 10, edx-dl stores its config file at %USERPROFILE%\.edx-dl\config.cfg (e.g., C:\Users\YourName\.edx-dl\config.cfg). If the file doesn't exist, run edx-dl once to generate it automatically.

Open the file in a text editor and add this line (use the same UA string that worked for you):

user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36"

Save the file, and edx-dl will use this User-Agent for all future requests.

3. Add YouTube-DL User-Agent Override (If Needed)

Since edx-dl relies on youtube-dl to download video content, you might also need to set a custom UA for youtube-dl. Add this line to the same config.cfg file:

youtube_dl_options = --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36"

4. Fallback: Use Browser Cookies

If the User-Agent tweak alone doesn't work, Cloudflare might be requiring a human verification check. You can bypass this by exporting your browser's cookies after logging into edX and passing them to edx-dl:

  • Log into edX in your browser (Chrome/Firefox) and confirm you're signed in.
  • Use a cookie exporter extension to save your cookies in Netscape format (save the file as cookies.txt).
  • Run edx-dl with the --cookies parameter:
edx-dl -u user@user.com --cookies cookies.txt COURSE_URL

This uses your authenticated browser session to bypass Cloudflare's checks.

内容的提问来源于stack exchange,提问作者AntC

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 03:25:57