Hello every one this is my first post.
I am making a traffic cam app and i like to use page scraping to pull information trafficland.com to a different page.
http://trafficland.com/city/DET/index.html
Following site generate a token every 10 minute
I like to pull only the pubtoken=283d5730c53e406f7ea051c4c89c31fd to a different page.
Source code of http://trafficland.com/city/DET/index.html:
Any help will be good.
Thank you
This is the code i started with
[code]<?php
/* Basic scraping demo with “foreach” and “regex” parsing
- Owen Mundy Copyright 2011 GNU/GPL */
// url to start
$url = “http://trafficland.com/city/DET/index.html”;
// get contents of url in an array
$lines = file($url);
// look for the string
foreach ($lines as $line_num => $line)
{
// find opening string
if(strpos($line, ‘
{
$get_content = true;
}
// if opening string is found
// then print content until closing string appears
if($get_content == true)
{
$data .= $line . "\n";
}
// closing string
if(strpos($line, "</div>"))
{
$get_content = false;
}
}
// use regular expressions to extract only what we need…
// png, jpg, or gif inside a src="…" or src=’…’
$pattern = “/src=[”’]?([^"’]?.*(png|jpg|gif))["’]?/i";
preg_match_all($pattern, $data, $images);
// text from link
$pattern = “/(<a.>)(\w.)(<.*>)/ismU”;
preg_match_all($pattern, $data, $text);
// link
$pattern = “/(href=[”’])(.*?)(["’])/i";
preg_match_all($pattern, $data, $link);
/*
// test if you like
print “
”;”;
print_r($images);
print_r($text);
print_r($link);
print “
*/
?>
body { margin:0; } .textblock { position:absolute; top:600px; left:0px; } span { font:5.0em/1.0em Arial, Helvetica, sans-serif; line-height:normal; background:url(trans.png); color:#fff; font-weight:bold; padding:5px } a { text-decoration:none; color:#900 }