Hello,
I am using a webpage which calculates for me some values, but I have a loooong list of values and I want this to be done non-interactively (through a loop ). The problem is that the webpage is not mine and I do not know how to submit many requests without actually having to press the submit button multiple times. Please help, I am tired of pressing this button and I'm not even close to finishing 1/10 of my data.
Thanks in advance
access code in a webpage to modify it
Moderator: General Moderators
Re: access code in a webpage to modify it
You can use fsockopen() or cURL library.
Re: access code in a webpage to modify it
For example if you want to send POST-data:
for the GET data you can see a example in the official documentation.
Code: Select all
<?php
$hostname = "www.somehost.com";
$path = "/print.php";
$line = "";
$fp = fsockopen($hostname, 80, $errno, $errstr, 30);
if (!$fp) echo "$errstr ($errno)<br />\n";
else
{
// POST-data
$data =
"name=".urlencode("Dmitriy")."&pass=".urlencode("my&pass")."\r\n\r\n";
// HTTP-header
$headers = "POST $path HTTP/1.1\r\n";
$headers .= "Host: $hostname\r\n";
$headers .= "Content-type: application/x-www-form-urlencoded\r\n";
$headers .= "Content-Length: ".strlen($data)."\r\n";
$headers .= "Connection: Close\r\n\r\n";
// send
fwrite($fp, $headers.$data);
// get
while (!feof($fp))
{
$line .= fgets($fp, 1024);
}
fclose($fp);
}
echo $line;
?>
Re: access code in a webpage to modify it
I'd recommend reading the RFCs for the HTTP protocol as well, yeah there's libraries like Curl ( and ultimately thats what you'll want to use ), but understanding what it is you're trying to do is pretty essential to understanding and ultimately solving the problem. Yeah http may seem self explanatory but it helps to know how post data is formatted and handled, etc..