开发者

How to get window.varName from a remote site

Overview: I'm trying to add an EventBrite event using the EventBrite API with nothing but the URL as an input.

For example, a user inputs [the url] and I should be able to pull the "eid" from [the url].

I know that the source of http://pitchevent-startups.eventbrite.com/ does this: [script] ... window.eid = "123456"; ... [/script] and I want to retrieve this 开发者_开发技巧"123456" value for my own purposes (adding the event to a list.)

How can I access this? Javascript preferred, but php will be OK too.

Thanks!


You could use PHP to get the eid, like this:

<?php
$url='http://pitchevent-startups.eventbrite.com/';
if (preg_match('/window\.eid\s*=\s*\"(\d*)\";/',file_get_contents($url),$match)){
    echo "eid: ".$match[1];
}
?>


You can't; cross-host requests are disallowed by browsers for security reasons.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜