我写了一个简单的网页爬虫来抓取expedia.com。使用Java Selenium HtmlUnitDriver,如果在本地运行,则能够成功从网站上抓取数据。
然而,当我将其部署到EC2服务器上时,它总是返回一个页面,显示 expedia 检测到它作为机器人,并展示验证码以证明正在访问的是人类。
我认为这可能与 EC2 服务器的 IP 地址有关,有些原因导致该地址被 expedia.com 列入黑名单?
我已经尝试抓取一些不关注/不进行人类测试的不同网站。
您有什么想法如何解决这个问题吗?
我尝试过的但仍被检测为机器人的事情:
- 将用户代理更改为我在本地浏览器中使用的内容
- 设置代理
更新: 实际上设置代理服务器会给我带来不同的错误:
当前 URL 是https://www.expedia.com/things-to-do/search?location=Paris&pageNumber=1
htmlString:
<!--?xml version="1.0" encoding="ISO-8859-1"?-->
<html>
<head>
<title>
500 Internal Server Error
</title>
</head>
<body>
<h1> Internal Server Error </h1>
<p> The server encountered an internal error or misconfiguration and was unable to complete your request. </p>
<p> Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error. </p>
<p> More information about this error may be available in the server error log. </p>
<hr>
<address> Apache/2.4.18 (Ubuntu) Server at www.expedia.com Port 443 </address>
</body>
</html>