Jump to content

etrader

Members
  • Posts

    315
  • Joined

  • Last visited

    Never

Everything posted by etrader

  1. My issue is about renaming. How in a php script I can command to re-write files in a folder?
  2. I have a folder containing files. I want to replace some characters in the file names (e.g. "_" with "-"), then make a list of new files (renamed ones). Thanks
  3. I have a list generated from an array by foreach as foreach ($list_array as $item) { echo "$item<br />"; } This is a long list, how can I separate the list to different pages? I mean the simplest way to do so
  4. Linked image in html has the form of <a href="http://site.com/link.html"><img class="not important" src='imagelink.jpg' title="not important" alt="not important"/></a> How to write href and src into an array during a foreach?
  5. Nice idea, but I got an error PHP Parse error: syntax error, unexpected '(' in the preg_match_all line
  6. It is easy to get image or link by DomDocument, but I did not find a way to get image with its target link. Imagine a html as <div class=image> <a href='http://site.com'><img src='imagelink.jpg'></a> </div> How to get both the image link and href? $dom = new DOMDocument(); @$dom->loadHTML($html); $xpath = new DOMXPath($dom); $hrefs = $xpath->evaluate("/html/body//div[@class='image']"); for ($i = 0; $i < $hrefs->length; $i++) { $href = $hrefs->item($i); Now to get the image and its href, we need first getElementsByTagName('a') and getElementsByTagName('img') but they do not work inside foreach. What's your idea?
  7. Thanks for your informative reply. One more question. Does the order has an influence on cURL processing? I mean changing the order of lines in curl_setopt($ch, CURLOPT_USERAGENT, 'Googlebot/2.1 (http://www.googlebot.com/bot.html)'); curl_setopt($ch, CURLOPT_URL,"http://www.site.com"); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_REFERER, 'http://www.google.com/bot.html'); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  8. When making a fake identity in cURL, we use curl_setopt($ch, CURLOPT_USERAGENT, 'Googlebot/2.1 (http://www.googlebot.com/bot.html)'); but which is better for the referrer: curl_setopt($ch, CURLOPT_AUTOREFERER, true); or curl_setopt ($ch, CURLOPT_REFERER, "http://www.google.com/bot.html");
  9. Imagine an html with the following structure <div class="item"> <div class="title"> <a class="title" href="http://www.domain.com/title.html">Title is here</a> </div> <div class="image"> <a href="http://www.domain.com/title.html"><img src=image.jpg /></a> </div> </div> How to make an array containing $title - $url - $image_url ?
  10. The only problem I have is that it writes pagename.html with chmod 644, and then unset cannot delete it or re-writing in the next run.
  11. The interesting point about simple_html_dom is the ability to capture links from a webpage as foreach($html->find('a') as $element) { $string = $element->href; } Is it possible to do so without simple_html_dom?
  12. What do you mean by that? I did not get it
  13. This will write "http://google.com" on pagename.html in cache directory? I must create this file to be written ?
  14. I successfully load a page by simple_html_dom.php (developed in simplehtmldom.sourceforge.net) as $html = file_get_html('externalpage'); But sometimes this make a high load on CPU and the page does not load for a long time (probably due to the external site server). How can I skip the process when it is not normal to avoid high CPU usage?
  15. I have a foreach loop as foreach ($xml->channel->item as $value){ $title = $value->title; $text = $value->text; echo "$title <br /> $text"; } I want to skip any entry in which the title contains a character like ":"
  16. I have two xml files as $xml1 = simplexml_load_file("1.xml"); $xml2 = simplexml_load_file("2.xml"); and want to merge them to create an array for a foreach process.
  17. I have some similar arrays. How I can combine them to shuffle the new array?
  18. Sorry for that. I thought that RFC 822 can have four-digit year. I think DATE_RFC2822 or DATE_RFC1123 suits my need
  19. I prefer to have four-digit year as Mon, 15 Aug 2005 15:52:01 +0000
  20. Yes! As I run the above-mentioned code, it produces Mon, 15 Aug 05 15:52:01 +0000
  21. sounds good , but it shows two-digit year instead of four-digit: 11 instead of 2011.
  22. How to change the date in format of ISO-8601 (example: 2005-08-15T15:52:01+0000) to RFC 822 (example: Mon, 15 Aug 05 15:52:01 +0000)?
  23. Actually, I loved the option1. It was so brilliant. Thanks a million
  24. It is a variable string. It is not a static text. It comes from a dynamic array.
×
×
  • 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.