向 LinkedIn 发出 HEAD 请求的 999 错误代码 [英] 999 Error Code on HEAD request to LinkedIn

查看:30
本文介绍了向 LinkedIn 发出 HEAD 请求的 999 错误代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在 PHP 应用程序中使用 curl HEAD 请求来验证通用链接的有效性.我们检查状态代码只是为了确保用户输入的链接有效.除 LinkedIn 外,所有网站的链接均已成功.

We're using a curl HEAD request in a PHP application to verify the validity of generic links. We check the status code just to make sure that the link the user has entered is valid. Links to all websites have succeeded, except LinkedIn.

虽然它似乎可以在本地 (Mac) 运行,但当我们尝试从任何 Ubuntu 服务器发出请求时,LinkedIn 会返回 999 状态代码.不是 API 请求,只是一个简单的 curl,就像我们对每个其他链接所做的一样.我们已经在几台不同的机器上尝试过并尝试改变用户代理,但没有骰子.如何修改我们的 curl 以便工作链接返回 200?

While it seems to work locally (Mac), when we attempt the request from any of our Ubuntu servers, LinkedIn returns a 999 status code. Not an API request, just a simple curl like we do for every other link. We've tried on a few different machines and tried altering the user agent, but no dice. How do I modify our curl so that working links return a 200?

示例 HEAD 请求:

A sample HEAD request:

curl -I --url https://www.linkedin.com/company/linkedin

Ubuntu 机器上的示例响应:

Sample Response on Ubuntu machine:

HTTP/1.1 999 Request denied
Date: Tue, 18 Nov 2014 23:20:48 GMT
Server: ATS
X-Li-Pop: prod-lva1
Content-Length: 956
Content-Type: text/html

更好地回应@alexandru-guzinschi.我们已经尝试屏蔽用户代理.总结我们的试验:

To respond to @alexandru-guzinschi a little better. We've tried masking the User Agents. To sum up our trials:

  • Mac 机 + Mac UA => 工作
  • Mac 机 + Windows UA => 工作
  • Ubuntu 远程机器 +(无 UA 更改)=> 失败
  • Ubuntu 远程机器 + Mac UA => 失败
  • Ubuntu 远程机器 + Windows UA => 失败
  • Ubuntu 本地虚拟机(在 Mac 上)+(无 UA 更改)=> 失败
  • Ubuntu 本地虚拟机(Mac 上)+ Windows UA => 有效
  • Ubuntu 本地虚拟机(Mac 上)+ Mac UA => 有效

所以现在我想他们会阻止任何不提供替代 UA 的 curl 请求,并且阻止托管服务提供商?

So now I'm thinking they block any curl requests that dont provide an alternate UA and also block hosting providers?

有没有其他方法可以从使用 PHP 的 Ubuntu 机器检查到 Linkedin 的链接是否有效,或者它是否会导致他们的 404 页面?

Is there any other way I can check if a link to linkedin is valid or if it will lead to their 404 page, from an Ubuntu machine using PHP?

推荐答案

看起来他们根据用户代理过滤请求:

It looks like they filter requests based on the user-agent:

$ curl -I --url https://www.linkedin.com/company/linkedin | grep HTTP
HTTP/1.1 999 Request denied

$ curl -A "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3" -I --url https://www.linkedin.com/company/linkedin | grep HTTP
HTTP/1.1 200 OK

这篇关于向 LinkedIn 发出 HEAD 请求的 999 错误代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆