Jump to content

how to get apart of apage using curl


medicalboy

Recommended Posts

i read an article about the pretty of curl in using,but i want to know away to get apart of apage not the whole page using curlex: multiupload.com if iwant to put the forms only in my site,how to do that, and is this can be done?i used this simple snippet:

$startcurl = curl_init();curl_setopt($startcurl, CURLOPT_URL, "http://www.multiupload.com");curl_setopt($startcurl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($startcurl, CURLOPT_HEADER, 0);$output = curl_exec($startcurl);curl_close($startcurl);

Link to comment
Share on other sites

You actually don't need CURL to fetch the page. You can just have

$contents = file_get_contents('http://www.multiupload.com');

Assuming the host has not disabled it... then again, if they have, why enable the CURL extension?The only way to get part of the content is to get the whole content first, then filter it out by going over its contents and checking if you've reached the position you want, then store from that point on the contents in a separate variable, then delete the full contents once you reach the end of the portion you want.This can be done either by extending the sample above, or by using fopen() first, then using stuff like fread() and the like to read some contents, checking it along the way. Doing it the first way is easier, but doing it this second way will mean your server will consume less memory (that doesn't necessarily mean it's going to be "faster", but if your host has a memory limit, that's one way to make sure you never reach it).If the page you had in mind was actually a valid XHTML page, you could've also used the DOMXPath class to only select the portion(s) you desire with a simple XPath expression, but alas, not with this site.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...