Jump to content

ItsPawl

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by ItsPawl

  1. Perhaps you could be more specific? Im not finding any where to set options (using mysql server 5.1 on windows XP with apache). I am pretty new to using mysql. Should say that im not sure that it is acctually getting a time-out. But it seems that way, since putting another connect in the middle of the code fixed the problem temporarily. Also i am using phpMyAdmin, and i can see some database variables but i can not change them from there (timeout is set to 10, and my script runs for 40-45 seconds).
  2. Im using mysql with a php script in which is start by connection to the database, and when the script has completed at the very end i close the connection. The problem is that the connection keeps closing on its own during execution. Does anyone know how i can increase the time the connection stays alive and where i would go to configure that?
  3. Im trying to get all the pages contents in a as short time as possible. As i understand it using multi-curl allows me to get all the pages in parallell instead of one after the other, thus reducing latency wait times. (im pretty sure file_get_contents for each would take longer, unless maybe used with threads somehow) Im only asking if anyone is familiar with these things and know of a still faster way since a low execution time is important in my program.
  4. Iv'e been looking in to methods of scraping data from pages and has found several examples of using multi-curl to achieve this. But i am not used to curl and is not completely sure how it works and i need to find the fastest reliable (i do need all, or close to all, pages every run) method of getting the content of a number of pages (about 160). Here is an example i got from searching the web which i managed to implement: <?php /** * *@param $picsArr Array [0]=> [url], *@$picsArr Array will filled with the image data , you can use the data as you want or just save it in the next step. **/ function getAllPics(&$picsArr){ if(count($picsArr)<=0) return false; $hArr = array();//handle array foreach($picsArr as $k=>$pic){ $h = curl_init(); curl_setopt($h,CURLOPT_URL,$pic['url']); curl_setopt($h,CURLOPT_HEADER,0); curl_setopt($h,CURLOPT_RETURNTRANSFER,1);//return the image value array_push($hArr,$h); } $mh = curl_multi_init(); foreach($hArr as $k => $h) curl_multi_add_handle($mh,$h); $running = null; do{ curl_multi_exec($mh,$running); }while($running > 0); // get the result and save it in the result ARRAY foreach($hArr as $k => $h){ $picsArr[$k]['data'] = curl_multi_getcontent($h); } //close all the connections foreach($hArr as $k => $h){ $info = curl_getinfo($h); preg_match("/^image\/(.*)$/",$info['content_type'],$matches); echo $tail = $matches[1]; curl_multi_remove_handle($mh,$h); } curl_multi_close($mh); return true; } ?> Since time is critical in my script i would ask if you think this is a good implementation or if you can point me in the direction of one that will save me noticeable run-time.
  5. Well, its not quite like that. I just wrote what came to mind. The pattern is the same as in the html though, so if there is any solution you can think of using regex then let me know. Trying to read up on regex, but seem like there is a lot to learn.
  6. Hello, Im pretty new to PHP and completely new to Regex, so bare with me. Im trying to extract data in from a html and save in my own variables. For example from something like: <fruit="Carrots">Carrots<class="fruit">4,3<class="fruit">13,00 i would like to save the fruit name and corresponding price which is the second number (13,00 in this case). I would then like to find the same for all listed fruits. I was thinking that it might be possible to extract those strings by using regex to filter out the information i want, but i cant figure out how. The problem for me is to extract the price which i know to be the second number, but i cant find a unique string that preceeds it and the start index of the number may also vary. Appreciate any help. *Edit Sry, i just realized that there where a child forum for regex questions. Hope to get help anyway if its no problem.
×
×
  • 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.