Jump to content

file_get_contents() in data changing page


waSaf

Recommended Posts

i have a problem with my application here.. hope u guys can help me out of it...

 

i have this page (www.data.com/page.asp)

 

where this page dislay somesort of daily data.

 

the data will change daily and to view previous data, we need to key in specific date and click on submit button. the form using $_POST data thus the URL of the page is remain the same regardless of the date selected and data displayed.

 

 

i need to get few data in this website including the previous one.

 

so i create a web-based apps (PHP) to display the html as string and strip the unneccessary string.

 

this is the main structure of my apps..

 

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

 

$code = file_get_contents("www.data.com/page.asp");

$html = htmlspecialchar($code);

 

<--function strip unwanted string and return required data here-->

 

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

 

 

the apps can run successfully, but only for current day data. since i use direct URL (www.data.com/page.asp), the apps will only grab data shown on the page by default. i cant grab the data for previous date.

 

so how to make my apps work as i intend? please help me. thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/182749-file_get_contents-in-data-changing-page/
Share on other sites

you can pass the date in querystring

 

(www.data.com/page.asp?date=26-nov-2009)

 

can necessary changes to throw output for the provided date !!.

 

the www.data.com/page.asp is not my own page.. it is an external page that i dont have control of it...

 

so is there any way php can detect the $_POST data of the page?

rephrase my problem....

 

 

i intend to get few data on this specific page, eg. www.data123.com/page.php

 

the method that i am using is, to parse the whole page into source code and use regex to filter what i want...

 

the page have a form ($_POST) so that the visitor can select the data base on the date submitted.

 

so, how to get the source code each time i submit new date? because im using file_get_contents here and the parameter used is only URL, while each time i submit new date, there is $_POST variable there...

Using cURL instead of file_get_contents you can send $_POST variables and capture the result. You can then scrape the result. Depending on what information your scraping you might be better off using some sort of DOMDocument rather than Regex, but thats another matter.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.