Jump to content

abhi_madhani

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

abhi_madhani's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi People, Please let me know is my introduction of problem not well presented or am I trying to do something that is not possible. Regards, Abhishek
  2. Hi, Any help would be appreciated in making Recursive function for this code. Regards, Abhishek
  3. Hi Phpfreaks, I have written this following code, it take any given URL of, and searches and list all 'ABC' links found in that given page. Then it goes through each 'ABC' link or page, searches and list all 'XYZ' links. The code works perfectly till here. Now I am planning to recursive search, where if more 'ABC' links are present inside each 'ABC' page, it should search and list them and 'XYZ' links, and this could go to many levels deep. It is more or less similar to 'Recursive Directory Listing' which lists the directory structure of folder and files, but in HTML page. I am still learning PHP Basic's, so any help even in simplifying my method of code would be grateful. I have attached the dummy file that I have been working on, kindly find it attached. Example :: ABC page ABC Link 1 XYZ Link 1.1 XYZ Link 1.2 XYZ Link 1.3 ABC Link 2 XYZ Link 2.1 XYZ Link 2.2 ABC Link 3 ABC Link 3-1 XYZ Link 3-1.1 XYZ Link 3-1.2 XYZ Link 3-1.3 ABC Link 3-2 XYZ Link 3-2.1 XYZ Link 3-2.1 XYZ Link 3-2.1 XYZ Link 3.1 XYZ Link 3.2 ABC Link 4 My code is as follows ...... <?php $url = "abclistA.html"; $needle = "abc"; $needle1 = "xyz"; echo '<table border="1">'; ABCfound: $acontents = file_get_contents($url); if (strpos($acontents, $needle)==!false) { preg_match_all('/id\s*=\s*\"abcs\".*?<\/table>a/isU',$acontents,$amatches); preg_match_all('/<a\s*href\s*=\s*\"(.*)\"\s*>\s*(.*)<\/a>/iSU',$amatches[0][0],$abc); foreach ($abc[0] as $akey => $abcrecord) { echo '<tr><td>'.$abc[2][$akey].'</td></tr>'; $xcontents = file_get_contents($abc[1][$akey]); if(strpos($xcontents, $needle1)!==false) { preg_match_all('/id\s*=\s*\"xyz\".*?<\/table>x/isU',$xcontents,$xmatches); preg_match_all('/<a\s*href\s*=\s*\"(.*)\"\s*>\s*(.*)<\/a>/iSU',$xmatches[0][0],$xyz); foreach ($xyz[0] as $xkey => $xyzrecord) { echo '<tr><td>'.$xyz[2][$xkey].'</td></tr>'; } // Planning to use this 'goto' shortcut, that when it again find ABC link inside ABC page, // it should go to begining of this code and rerun it. // However this time $url will be changed with suburl that needs to scanned. // This doesn't seem to work. /*if (strpos($xcontents, $needle)==!false) { $url = $abc[1][$akey]; echo " S-MF "; goto ABCfound; } else { echo " S-MNF "; } */ } else { echo " SNF "; } } } else { echo " MNF "; } echo '</table>'; ?> 18464_.zip
  4. I am trying to extract URL's from html page by using following Regular Expression. <a href=" (....till....) "> Name </a> preg_match_all('/<\s*a\s+[^>]*href\s*=\s*[\"\']?([^\"\'>]+)[\"\']>(.*)<\/a>/isU' It works perfectly on most URL's. But it fails to recognise following kind of urls in HTML. http://en.wikipedia.org/wiki/B'ham - Note the single quotation in the B'ham. The URL's in the HTML are not encoded for special characters, hence I have to build my regex to count in URL's which have special characters in them. Could anyone guide me for solutions towards this bend?
  5. Hi, I am trying to convert a String date into numeric date using PHP function's, but haven't found such function. Had a look at date(), strtotime(), getdate(); e.g. Apr 1 2011 -> 04-01-2011 Could someone please shed some light on this? Regards, Abhishek
  6. Hey Works like charm. Thanks a lot, I just learned about Regex basics, and hadn't come across sub patterns till now, very useful. Regards, Abhishek
  7. Hi, I am using a PHP's preg_match() to search through string, and displaying its pattern, but want to display only part of it. E.g. looks like preg_match('/shape=\'.*\'/sU',$value,$matches); The search displays " class='PHPfreaks' " From the search I would like to display only the part highlighted in bold. " '/shape=\'.*\'/sU' " So the final value to be displayed should be " PHPfreaks " Regards, Abhishek
  8. Hi, I checked this it doesn't seem to work, there need be included a character after "ST.* to allow to go to next line, I think. \<div id="ST.*?house=\'Anything\'>\s*<\/div>\s*<\/div>\s*<\/div>/is Also this is very good website, where one could check the outcome of the preg_match with regex. http://regex.larsolavtorvik.com/ Could someone please help me with this? Regards, Abhishek
  9. Hi, I am not that good with understanding REGEX/REGEXP functions but, Could someone please let me know as how can I search through html code for a particular tag having a definite start and definite end. E.g. HTML Code below, it has definite Start of <div id="ST and definite End of house='Anything'></div></div></div> <div id="ST12345678_st" class="r_right_col"> <div class=""></div> <div id=""><span class=""></span></div> <div class=""></div> <div class=""><span class=""></span></div> <div class=""></div> <div class=""> <div style="" id="" fname=Abhishek lname='madhani' division=8C house='Anything'> </div> </div> </div> So the HTML file which I have, has the this particular tag being repeated atleast more than 50 times in whole code. And I am planning to extract each of them seperately. So if someone could help me with REGEX to search for this particular tags in whole file, would be really helpful. Regards, Abhishek Madhani
  10. Hi, I am trying to verify if the given url exists or not, by using file_exists() function. It always returns 'FALSE' , according to my understanding it happening because the file to be checked on the given url is located in safe mode. Could anyone please suggest as to how this could be overcome, by similar function or by using alternative method. Regards Abhishek Madhani
  11. Hi, I actually tried running the script, but it didn't work because of missing files, if you could upload the sample somewhere, it would be easier to figure out your explanation. Regards, Abhishek
  12. Hi In If, ElseIf, Else logic, the ElseIf logic is only run, when its preceding IF/ElseIf has appeared to be false. and if its comes true it makes a exit, (That's the case I think is with your code.) Because the second ElseIF (Instructor) is coming true, it straight away execute the that logic, and makes a exit without reading ElseIf (Course). So I hope it clears the road bit. Regards
  13. Hi, The url can be accessed in normal browser, Your suggestion is possible that the source server has script in place, which only allows browsers to make the request, and not any to any other type of applications or scripts. My website url might not be blocked, but it could be my hosts server's ip address that is blocked. I will try to implement curl() to accomplish this task, and will see how can the identity be faked as a real browser. Thanks for your suggestion, will post here back if any of the solutions works.
  14. hi, try this solution <?php $paragraph = '300 had not been then, greece would not have been now'; $paragraph1 = 'if 300 had not been then, greece would not have been now'; $var1 = '300'; if (stripos($paragraph, $var1)=='0') { echo 'it works'; } else { echo 'it doesnt'; } ?> now try changing $paragraph with $paragraph1 in stripos. Regards,
  15. Hi, I am trying to fetch a file with function file_get_contents() from a website, but am getting following error. [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in /data/22/1/27/17/1842180/user/1999295/htdocs/web/modules/index.php on line 14. using following code, $content = file_get_contents($source); $handle = fopen($destination, 'wb'); fwrite($handle, $content); fclose($handle); does it have something to with http header, which might be required to set as HTTP/1.1 in php Regards, Abhishek
×
×
  • 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.