跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[程序员] 第一天玩爬虫就遇到 418 恼火 -______-------

发表于

目标地址: https://search.shopping.naver.com/search/category?adQuery&brand=188869&catId=50000629

分析过程

step1: 国内电信,不用任何代理或 vpn 直接用浏览访问就出现 418 ,初步确定是这个站点封禁国内的。(不知道移动和联通是否也这样)

step2: 启动 vpn 访问用浏览器访问,打开页面正常。

接下来 curl 的奇怪问题 操作系统是: macos-14.5

确定了 curl 终端请求都是会经过代理的

curl 'https://search.shopping.naver.com/search/category?catId=50000630'

尝试 1:在终端:macos-curl 8.6.0 请求返回的是 418

尝试 2: 用 docker-debian-curl 7.52.1 请求返回 200 却是可以成功的

尝试 3: 用 docker-debian-curl 7.88.1 请求返回的是 418

python 和 scrapy 的奇怪问题

确定了请求都是会经过代理的

Python 3.9.6 Scrapy 2.8.0

cookies = {
    'NACT': '1',
    'NAC': 'bupOBQQrA6vz',
    'NNB': 'HTF6RRY7SDCGM',
    'BUC': 'fHVI0Qf4gDQah4m9TkLBxmg7BIZvwdowShJv6ZPLiG8=',
    'OEP_BUCKET_ID': '1',
    'SHP_BUCKET_ID': '9'
}

headers = {
    # 'cookie': 'NACT=1; NAC=bupOBQQrA6vz; NNB=HTF6RRY7SDCGM; BUC=fHVI0Qf4gDQah4m9TkLBxmg7BIZvwdowShJv6ZPLiG8=; OEP_BUCKET_ID=1; SHP_BUCKET_ID=9',
    'sec-ch-ua': '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0'
}

url = 'https://search.shopping.naver.com/search/category?catId=50000629'

requests.get(url, headers=headers, cookies=cookies)

尝试 python 请求:返回是 200 正常

尝试 scrapy 请求:返回是 418 失败

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.