我正在尝试使用网络请求抓取网站,但在访问端点时不断收到 400 错误

发布于 2025-01-15 12:55:11 字数 1843 浏览 0 评论 0原文

这是我尝试从中获取资源的代码: 请看下面的代码 另外,当我尝试获取资源时,我收到 400 错误(错误请求)

cookies = {
    '_ga': 'GA1.1.1766722278.1645957227',
    'prefetchAd_4697299': 'true',
    '__atuvc': '12%7C9%2C0%7C10%2C28%7C11',
    '__atuvs': '6235d2ce357a7e8e002',
    '_ga_8ST3M82VHM': 'GS1.1.1647694542.8.1.1647694763.0',
}

headers = {
    'authority': 'www.2embed.ru',
    'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="99", "Google Chrome";v="99"',
    'accept': '*/*',
    'x-requested-with': 'XMLHttpRequest',
    'sec-ch-ua-mobile': '?1',
    'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Mobile Safari/537.36',
    'sec-ch-ua-platform': '"Android"',
    'sec-fetch-site': 'same-origin',
    'sec-fetch-mode': 'cors',
    'sec-fetch-dest': 'empty',
    'referer': 'https://www.2embed.ru/embed/tmdb/movie?id=299534',
    'accept-language': 'en-GB,en;q=0.9,en-US;q=0.8',
    # Requests sorts cookies= alphabetically
    # 'cookie': '_ga=GA1.1.1766722278.1645957227; prefetchAd_4697299=true; __atuvc=12%7C9%2C0%7C10%2C28%7C11; __atuvs=6235d2ce357a7e8e002; _ga_8ST3M82VHM=GS1.1.1647694542.8.1.1647694763.0',
}

params = {
    'id': '1615802',
    '_token': '03AGdBq240F46WlukGcDIXB1s9JvMCFA1AOyT9QDxHLFx3SKOO4wqGbywApJqnCnNri8koRKpGh7V53e-kYO5yocfYB9TxXKpKCU2dK3I9F-Qiqul1PRLURJDGdEwnJC_d_QQNjG3ib0OAZ2QekPotlr5ZLQ7bqqVWypkqVwIz1-kEmHhWY-DmdWWFYMILsDLUioXFSfnG7hv3ai4SN_E00g3W4LezZspWiW_RVliGNKWxhiaCCRZXIDEWCLMv_y-4HNjNxciTCrCv5HVdOwWW2offh_udiSb1lWvbf1Oe_VSJ26qXkB6hEUZUAtmCsFY4M3JD6YSWolN9PYpSKJXj-3gNN9IFSbu6laNfi7DuOLiZi9sRvZhrzbO75Zii4MSqd94m_IcNN5kxQqRuHHJVvvrlNSQkSNswk9wfPUDL09ikmolzvfDIDya3JxsNv6rz05lDYLiLM_4xN2Cy1xdMD74YME8CvonF7A',
}

response = requests.get('https://www.2embed.ru/ajax/embed/play', headers=headers, params=params, cookies=cookies)

This is the code I am trying to fetch the resource from:
Please have a look below at the code
Also when I am trying to fetch the resource I am getting a 400 Error (Bad Request)

cookies = {
    '_ga': 'GA1.1.1766722278.1645957227',
    'prefetchAd_4697299': 'true',
    '__atuvc': '12%7C9%2C0%7C10%2C28%7C11',
    '__atuvs': '6235d2ce357a7e8e002',
    '_ga_8ST3M82VHM': 'GS1.1.1647694542.8.1.1647694763.0',
}

headers = {
    'authority': 'www.2embed.ru',
    'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="99", "Google Chrome";v="99"',
    'accept': '*/*',
    'x-requested-with': 'XMLHttpRequest',
    'sec-ch-ua-mobile': '?1',
    'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Mobile Safari/537.36',
    'sec-ch-ua-platform': '"Android"',
    'sec-fetch-site': 'same-origin',
    'sec-fetch-mode': 'cors',
    'sec-fetch-dest': 'empty',
    'referer': 'https://www.2embed.ru/embed/tmdb/movie?id=299534',
    'accept-language': 'en-GB,en;q=0.9,en-US;q=0.8',
    # Requests sorts cookies= alphabetically
    # 'cookie': '_ga=GA1.1.1766722278.1645957227; prefetchAd_4697299=true; __atuvc=12%7C9%2C0%7C10%2C28%7C11; __atuvs=6235d2ce357a7e8e002; _ga_8ST3M82VHM=GS1.1.1647694542.8.1.1647694763.0',
}

params = {
    'id': '1615802',
    '_token': '03AGdBq240F46WlukGcDIXB1s9JvMCFA1AOyT9QDxHLFx3SKOO4wqGbywApJqnCnNri8koRKpGh7V53e-kYO5yocfYB9TxXKpKCU2dK3I9F-Qiqul1PRLURJDGdEwnJC_d_QQNjG3ib0OAZ2QekPotlr5ZLQ7bqqVWypkqVwIz1-kEmHhWY-DmdWWFYMILsDLUioXFSfnG7hv3ai4SN_E00g3W4LezZspWiW_RVliGNKWxhiaCCRZXIDEWCLMv_y-4HNjNxciTCrCv5HVdOwWW2offh_udiSb1lWvbf1Oe_VSJ26qXkB6hEUZUAtmCsFY4M3JD6YSWolN9PYpSKJXj-3gNN9IFSbu6laNfi7DuOLiZi9sRvZhrzbO75Zii4MSqd94m_IcNN5kxQqRuHHJVvvrlNSQkSNswk9wfPUDL09ikmolzvfDIDya3JxsNv6rz05lDYLiLM_4xN2Cy1xdMD74YME8CvonF7A',
}

response = requests.get('https://www.2embed.ru/ajax/embed/play', headers=headers, params=params, cookies=cookies)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文