I wanted make "a service on one site" to be available on my site. so I decided to use cURL(Before I have tried using Iframe but it is not worthy as that site has ads, I want Specific Part Etc.) so basically i want specific tag(not div) from that remote site On my website's webpage. I googled a lot as I don't know php and found that cURL is used to do what I wanted. After googling more I have Made This Simple Script
<?php
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://www.autogeneratelink.com/");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec ($curl);
curl_close ($curl);
echo "$output";
?>
As I don't know php I could only make this much so basically what this code do is display whole site on my webpage but I want specific part (Things Between This Tag <form method="POST" action=""></form>
)
Also I have tried to enter a value in my webpage and clicking "Generate" button but it do not do Anything. It just refreshes the page.
Pls.. Help me regarding this I want Button to work properly and the Content Between That tag Only.
Thank You Guys For Helping..
You can run preg_match
on the results of curl to obtain the HTML you want:
<?php
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://www.autogeneratelink.com/");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec ($curl);
curl_close ($curl);
preg_match('/<form method="POST" action="">.*<\/form>/s', $html, $matches);
$form = $matches[0];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link href="http://www.autogeneratelink.com/css/bootstrap.min.css" rel="stylesheet">
<link href="http://www.autogeneratelink.com/css/autogl.css" rel="stylesheet">
<style>
button#submit{
background-color: yellow;
}
</style>
</head>
<body>
<h1>My Awesome Page</h1>
<p>Hello!</p>
<?php echo $form ?>
<p>Bye!</p>
</body>
</html>
However, the form is powered by the following script, which makes an Ajax request to a PHP script on a domain outside of your control. You will be clobbered by the cross-origin policy and your form won't work. There is no way that I know of to get around this. Sorry!
Plus, at this point, you should also start thinking about the ethics of what you are doing (i.e. stealing).