Jump to content

help with scraping (fopen ...)


billy2shoe

Recommended Posts

hi there...

I aim trying to do some code that basically reads a web-page and extracts certain information from it

 

first: I am trying to write some code that reads a URL .. and prints the contest of the site out

 

why doesnt this code work below????

I don't think the fopen("$URL", "r"); is working correctly

 

=================================================

<?

$URL = "http://www.dur.byethost4.com/screen_two/r_rules.php";

$file = fopen("$URL", "r");

$r = "";

do{

    $data = fread($file, 8192);

    $r .= $data;

    echo "data: $data \n";

}

while(strlen($data) != 0);

?>

 

 

 

 

 

Link to comment
Share on other sites

hmmm interesting ...

 

i read that site u sent me and use the code (example) ...and it doesnt work .. perhaps im doing something wrong ..  the link is: http://au2.php.net/file

 

(this is the code)

 

<?php

 

$lines = file('http://www.example.com/');

foreach ($lines as $line_num => $line) {

  echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";

}

 

?>

Link to comment
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.