du521521521 2018-03-06 15:59
浏览 43

使用Scriptable Web Browser从URL中提取信息

I'm trying to extract specific numbers using "PHP Scriptable Web Browser". So far I managed to extract string information that would be the usual thing one gets when doing a "view source" on Browser. Here's my code:

<?php
error_reporting(-1);
ini_set('display_errors', 'On');
header('Content-type: text/html; charset=utf-8');
require_once('simpletest/browser.php');
$browser = &new SimpleBrowser();
$browser->get('https://www.betfair.com/exchange/plus/football/');
$content[] = $browser->getContent();
preg_match("/<title>(.*)/", $content[0], $matches);
print $matches[1];
?>

I deployed this on my server and it returns the expected string.

The problem is that I don't know how to get the numbers I want, which in this case, are the odds of the games.

Using Chrome and developer tools I see the json information and there I see all those numbers. Looking around, I see that one way to get the JSON would be something like:

$json = file_get_contents('https://www.betfair.com/exchange/plus/football/');

But I couldn't make PHP Scriptable Web Browser to use this.

I know that people use "Beautifulsoup" for this kind of job, but I cannot use python/django and it has to be in PHP or Java.

Than I need to loop through all pages (https://www.betfair.com/exchange/plus/football/page/N) where N is not known in advance... and be able to store the numbers as variables and "print" them on Browser.

I apologize if this is confuse/open-ended/unclear. I know very littler about PHP, scrapping etc, so ANY help is s big help.

Thanks.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
    • ¥15 教务系统账号被盗号如何追溯设备
    • ¥20 delta降尺度方法,未来数据怎么降尺度
    • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效