Jump to content

Recommended Posts

I'm trying to find a tutorial or something that will allow me to show movie times from Fandango on my site.

I found one thing, but it's not displaying anything.

 

<?
$url = "http://www.fandango.com/san+diego_ca_movietheatershowtimes";
$file = "content.inc"; 
$unique_start = '<table width="677" border="0" cellspacing="0" cellpadding="0">'; 
$unique_end = '<table width="678" border="0" cellspacing="0" cellpadding="0">';

ini_set('max_execution_time', '0');
flush ();

// fetch domain from url
$fetch_domain = parse_url($url);

$fetch_domain = $fetch_domain[host];

// Host checking code
$socket_handle = fsockopen("$fetch_domain", 80, $error_nr, $error_txt,30);
if(!$socket_handle)
{

print("Cannot make a connection to: $fetch_domain and therefore cannot collect your requested data");
$contents = implode("",@file( $file ) );
echo $contents;
exit;
}

$fd= fread(fopen("$url", "r"), 100000);

if ($fd)
{
$start= strpos($fd, "$unique_start");
$finish= strpos($fd, "$unique_end");
$length= $finish-$start;
$code=substr($fd, $start, $length);
}

echo $code;
$tmpfile = fopen($file,"w+");
$fp = fwrite($tmpfile,$code);
fclose($tmpfile);
flush ();
?>

 

Does anybody know how I could modify this script, or a good tutorial to show how this can be done?

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/145503-grab-content/
Share on other sites

OKay this is just a basic idea.. but should help..

your need to tweak the RegEx (we have a RegEx section)

<?php
$html = file_get_contents("http://www.fandango.com/san+diego_ca_movietheatershowtimes");
preg_match_all('%<div class="title">.*?<h4>.*?<a[^>]*?>\s*(.*?)</a>.*?</h4>.*?</div>.*?<div\s+class="times">(.*?)</div>%sim', $html, $result, PREG_PATTERN_ORDER);
$result = $result[0];
foreach($result as $r)
{
echo $r;
}
?>

 

Please note the RegEx was written in a kinda rush.. so some clean up is required

Link to comment
https://forums.phpfreaks.com/topic/145503-grab-content/#findComment-763956
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.