如何与用户代理一起使用 Wget 下载网页

发布于 2024-12-27 03:56:38 字数 984 浏览 2 评论 0原文

我正在尝试使用 Wget 下载此页面。这是页面链接:

http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&rt=nc&item=250972882769&si=a8iGAIchyvEbn7KveYFZ5QbEE7o%3D&print=all&category=31387< /p>

并且这是我的命令:

wget -O ebay.html --user-agent="Mozilla/5.0 (Windows NT 5.2; rv:2.0.1) Gecko/20100101 Firefox/4.0.1" "http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&rt=nc&item=250972882769&si=a8iGAIchyvEbn7KveYFZ5QbEE7o%3D&print=all&category=31387"

当我使用它使用浏览器访问页面时,它可以工作 美好的。当我使用 Wget 时,它会下载另一个页面,而不是原始页面。我认为问题出在用户代理上。解决办法是什么?

I am trying to download this page using Wget. Here is the page link:

http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&rt=nc&item=250972882769&si=a8iGAIchyvEbn7KveYFZ5QbEE7o%3D&print=all&category=31387

And here is my cmd:

wget -O ebay.html --user-agent="Mozilla/5.0 (Windows NT 5.2; rv:2.0.1) Gecko/20100101 Firefox/4.0.1" "http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&rt=nc&item=250972882769&si=a8iGAIchyvEbn7KveYFZ5QbEE7o%3D&print=all&category=31387"

When I use it to access the page using a browser it works fine. When I use Wget, it downloads another page, not the original one. I think the problem is for user-agent. What's the solution?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自此以后,行同陌路 2025-01-03 03:56:38

问题不在于用户代理,而在于缺少 cookie。解决方案是

  1. 使用 wget --save-cookies=ebay-cookies 检索正常的产品页面,
  2. 从该 HTML 文件中获取“打印”链接 URL。 (我是手工完成的,显然您应该编写一个脚本来执行此操作。)
  3. 使用 wget --load-cookies=ebay-cookies 检索“打印”URL

我使用随机产品页面尝试了它;它起作用了。

The problem isn't user-agent, it's a missing cookie or cookies. The solution is

  1. Retrieve the normal product page with wget --save-cookies=ebay-cookies ,
  2. Fish the "Print" link URL out of that HTML file. (I did this by hand, you should obviously write a script to do it.)
  3. Retrieve the "Print" URL with wget --load-cookies=ebay-cookies

I tried it with a random product page; it worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文