PHP 和 AJAX url 获取数据
PHP and AJAX url get data
我在抓取 URL 时遇到问题,如果我使用 Chrome 的开发工具,我会看到 URL 并预览内容,但如果我打算打开 URL 来自浏览器 return 我找不到 404。
这是 URL 和 AJAX 数据。我需要 parte.of 赔率比较:
http://www.betexplorer.com/soccer/england/premier-league/wolves-manchester-city/Kz6hM15m/
这是一个 AJAX 数据 URL :
www.betexplorer.com/gres/ajax/matchodds.php?p=0&e=Kz6hM15m&b=1x2 这个URL return 404 在浏览器中找不到但是在fiesta URL 显示赔率。
是否有可能来自 secondo url?
的数据
谢谢。
在快速检查您在问题中提到的网站后,我发现它在处理请求时正在检查引荐来源网址和 user-agent。
添加值为“http://www.betexplorer.com/”的 header "Referer" 和一个随机的 "browser-like" 用户代理,会产生具有请求赔率的 json 响应:)
例如:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.betexplorer.com/gres/ajax/matchodds.php?p=0&e=Kz6hM15m&b=1x2");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.12011-10-16 20:23:00");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://www.betexplorer.com/");
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
$output = curl_exec($ch);
curl_close($ch);
我在抓取 URL 时遇到问题,如果我使用 Chrome 的开发工具,我会看到 URL 并预览内容,但如果我打算打开 URL 来自浏览器 return 我找不到 404。
这是 URL 和 AJAX 数据。我需要 parte.of 赔率比较: http://www.betexplorer.com/soccer/england/premier-league/wolves-manchester-city/Kz6hM15m/ 这是一个 AJAX 数据 URL : www.betexplorer.com/gres/ajax/matchodds.php?p=0&e=Kz6hM15m&b=1x2 这个URL return 404 在浏览器中找不到但是在fiesta URL 显示赔率。 是否有可能来自 secondo url?
的数据谢谢。
在快速检查您在问题中提到的网站后,我发现它在处理请求时正在检查引荐来源网址和 user-agent。
添加值为“http://www.betexplorer.com/”的 header "Referer" 和一个随机的 "browser-like" 用户代理,会产生具有请求赔率的 json 响应:)
例如:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.betexplorer.com/gres/ajax/matchodds.php?p=0&e=Kz6hM15m&b=1x2");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.12011-10-16 20:23:00");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://www.betexplorer.com/");
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
$output = curl_exec($ch);
curl_close($ch);