Jump to content

scrape a page help


Go to solution Solved by redarrow,

Recommended Posts

Hi there how do you scrape a page from a website.

 

I want the data whats in between the divs how it done cheers.

 

<div style="display:block;" class="skedStartDateSite">
Sun Mar 17, 2013
</div>

 

i am trying to learn this so please help.

 

i need examples cheers.

Edited by redarrow
Link to comment
https://forums.phpfreaks.com/topic/275768-scrape-a-page-help/
Share on other sites

how this wrong i want all the dates from the page what i done wrong?

 

 

<?php
 $data = file_get_contents('http://www.nhl.com/ice/schedulebyweek.htm?date=03/17/2013');

 $regex = '<div style="display:block;" class="skedStartDateSite">[a-z0-9\,]</div>';

 preg_match($regex,$data,$match);

 var_dump($match);

 echo $match[1];

 ?>
Link to comment
https://forums.phpfreaks.com/topic/275768-scrape-a-page-help/#findComment-1419127
Share on other sites

<?php
 



$doc = new DOMDocument();
libxml_use_internal_errors(true);
$doc->load('http://www.nhl.com/ice/schedulebyweek.htm?date=03/17/2013');


$xpath = new DOMXPath($doc);
$nodes = $xpath->query("//div[@class='skedStartDateSite'/a");

foreach ($nodes as $node) {
    echo $node->nodeValue();
}




?>

how this wrong foreach error

Link to comment
https://forums.phpfreaks.com/topic/275768-scrape-a-page-help/#findComment-1419136
Share on other sites

<?php

$file_string = file_get_contents('http://www.nhl.com/ice/schedulebyweek.htm?date=03/17/2013');

preg_match('/<div style="display:block;" class="skedStartDateSite">(.*)<\/div>/i', $file_string, $title);

$title_out = $title[1];


//print_r(explode(' ', $title_out));

$title_out=explode(' ', $title_out);

$date=$title_out[1].$title_out[2].$title_out[3];
$team1=$title_out[39];
$team1=str_replace('href="javascript:void(0);">','',$team1);
$team2=$title_out[70];
$time=$title_out[81].$title_out[82].''.$title_out[83];
$time=str_replace('class="skedStartTimeLocal">','',$time);

echo "<table><tr><td> Date of game <td> $date</td> <td>Team playing</td> <td>$team1 VS $team2</td> <td> Time playing</td><td>$time</td></tr></td></table>";

?>

i need this result but propery scraped

Link to comment
https://forums.phpfreaks.com/topic/275768-scrape-a-page-help/#findComment-1419175
Share on other sites

You probably will not get any help here, as most of us will view a sites TOS before helping scrape the pages:

NHL TOS

 

2. SERVICES AND CONTENT
The NHL Parties currently provide users with various features and services, including bulletin boards, fan-to-fan chats, social media, shopping, auctions, NHL and Team video offerings, NHL GameCenter LIVE, NHL Vault, fantasy games, and other interactive and non-interactive features, all of which may be updated, deleted or otherwise modified from time to time at the discretion of the NHL Parties.   In addition, the NHL Parties also provide access to certain footage (video and audio), photographs, text, images, statistics, logos and other media and intellectual property related to or otherwise associated with the National Hockey League, its member clubs and the sport of hockey (collectively, the "Content"). Some of our features, services and Content require an access fee (the "Pay Services") and others are free to use without the payment of an access fee (the "Basic Services"). The Basic Services and the Pay Services, including all features, services and Content on the Websites, are collectively referred to as the "Services". Unless stated otherwise, the Websites, the Services and the Content are subject to the TOS. You understand and agree that the Websites, the Services and the Content are provided "AS-IS" and that the NHL Entities (as defined below) assume no responsibility in connection with your use of the Websites, the Services or the Content.  The Websites, the Services and the Content are provided for your personal, non-commercial use, entertainment and enjoyment. Under the TOS, you may download or stream certain Content and Services available on the Websites to a single personal computing device for your personal use and entertainment. You may not use any of the Content or Services for commercial purposes. The Services may not be viewed in areas open to the public or in commercial establishments where multiple people can view it at the same time. Further, you may not copy, distribute, modify, republish, broadcast, retransmit or publicly display any of the Content or Services, create derivative works of them, charge admission for their viewing, or transmit or distribute running accounts of them, unless you have the prior written permission of NHL ICE, which permission may be withheld in NHL ICE's sole discretion. The Content is provided for your reference only, and you should not rely upon it for any purpose. NHL ICE is not responsible for the Content's accuracy and reliability. It is your responsibility to impose any viewing restrictions on other family members or guests, as you think appropriate. NHL ICE is not responsible to you or anyone else based on the content of the Content or Services.

Link to comment
https://forums.phpfreaks.com/topic/275768-scrape-a-page-help/#findComment-1419221
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.