[Solved] Getting data from a public website
Moderator: General Moderators
[Solved] Getting data from a public website
I have a question about getting data from a website. I have a mysql file on my server with fields such as item, description, # pieces_bulk, color, etc. The item field is has valid items that I can access a webpage with. All of the other fields are blank. For instance, item 12345, I can generate a string for a webpage; http://www.bigcompany.com/cgi-bin/products/?item=12345. This works, but what I want to do is write a script to grab data for description and other fields that are located on the page. Is this possible with PHP? Thanks!
Last edited by Oxydude on Tue Aug 03, 2004 7:16 pm, edited 2 times in total.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
sure is 
example:
example:
Code: Select all
<?php
// mysql connect here
$item = mysql_result($query, 1, 0);
$url = 'http://www.bigcompany.com/........' . $item;
$html = file_get_contents($url);
preg_match('#description:(.*?)pieces:(.*?)#is', $html, $matches);
var_dump($matches);
?>file_get_contents
Is there a function similar to file_get_contents in PHP/4.0.6?
Fatal error: Call to undefined function: file_get_contents() in /var/www/html/nsb/getwordweb.php
Fatal error: Call to undefined function: file_get_contents() in /var/www/html/nsb/getwordweb.php
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
Re: file_get_contents
Fopen and Fread do the same things.Oxydude wrote:Is there a function similar to file_get_contents in PHP/4.0.6?
Fatal error: Call to undefined function: file_get_contents() in /var/www/html/nsb/getwordweb.php
Oh, and for the third time, upgrade!
Listed below is my program:
<?php
$word = "test";
$html = file_get_contents('http://www.bigcompany.com/cgi-bin/catalog?va=chair123');
echo $html
?>
When I call this program up in a browser, it will display the entire webpage chair123 with all of its details.
I am trying to get the only the shipping dimensions for the product and I tried adding the following:
preg_match("dimensions:", $html, $matches);
var_dump($matches);
I now get the following message: Warning: Delimiter must not be alphanumeric or backslash in /var/www/html/nsb/getwordweb.php on line 13
array(0) { }
What I need to do is read into a variable the 30 characters that follow the first instance of "Dimension:"
Is there a php command that will do this?
Thanks!
<?php
$word = "test";
$html = file_get_contents('http://www.bigcompany.com/cgi-bin/catalog?va=chair123');
echo $html
?>
When I call this program up in a browser, it will display the entire webpage chair123 with all of its details.
I am trying to get the only the shipping dimensions for the product and I tried adding the following:
preg_match("dimensions:", $html, $matches);
var_dump($matches);
I now get the following message: Warning: Delimiter must not be alphanumeric or backslash in /var/www/html/nsb/getwordweb.php on line 13
array(0) { }
What I need to do is read into a variable the 30 characters that follow the first instance of "Dimension:"
Is there a php command that will do this?
Thanks!