Make a curl POST request from scraped data

0

I scraped a website using the simple DOM php parser :

<?php
include 'domparse.php';
$html = file_get_html('http://oceanofgames.com/rebel-galaxy-free-download/');
foreach($html->find('form[action="http://oceanofgames.com/Cloud-VPS-Download.php"]') as $element) 
echo $element;
?>

And I ended up with something like :

<form action="http://oceanofgames.com/Cloud-VPS-Download.php" target="_blank" method="post">
  <input type="hidden" name="filename" value="Rebel_Galaxy.zip" /><br />
  <input type="hidden" name="filesize" value="2GB" /><br />
  <input type="hidden" name="id" value="85.25.103.44" /></p>
  <div align="center">
    <input type="image" alt="Download" height="99" src="http://oceanofgames.com/wp-content/uploads/2013/09/button-download.png" width="184" />
  </div>
</form>

I need to make a POST server to the server using these credentials of the form using cURL and I have no idea how to do it. Please guide me.

Sachin Kamath

Posted 2015-10-24T19:21:05.197

Reputation: 101

I think maybe something like curl --data "filename=Rebel_Galaxy.zip&filesize=2GB&id=85.25" https://example.com/resource – barlop – 2015-10-24T19:40:42.360

I need to scrape a lot of urls like that, how can I isolate each of the elements? You know, dynamically. – Sachin Kamath – 2015-10-25T00:23:55.727

You really need to elaborate on scraping URLs and isolating elements. 'cos that line I gave you doesn't scrape a URL (it doesn't GET the URL, it doesn't then get any info from the response to a GET of the URL) It just does a POST which gives the names and values for each element so the server gets the data as if it had been inputted into the page,. If you are asking how can you GET a URL and load the names of every element into an array.. that's a question for stackoverflow, if it hasn't been asked yet. – barlop – 2015-10-25T10:51:20.810

No answers