Page 3 of 8

Re: Php link exporter

Posted: Thu Nov 26, 2009 4:17 am
by The_L
Can anyone please help me?? :/

Re: Php link exporter

Posted: Thu Nov 26, 2009 6:52 am
by iankent
Hi The_L

Glad you got it working, and sorry I missed your email, only just spotted it!

Not too sure what you mean by the last bit? If your code is picking up the URLs then it should be picking up URLs wherever they appear. Could you give a specific example of a URL it doesn't pick up?

Re: Php link exporter

Posted: Thu Nov 26, 2009 2:47 pm
by The_L
Okay here:

This is the one with this code:

Code: Select all

 
$stag="<a href=\"http://rapidshare.com";
$etag="\" class=\"bbc_link new_win\" target=\"_blank\">";
And this one is the one with this code:

Code: Select all

 
$stag="<a href=\"http://rapidshare.com";
$etag="</a><br />";
 
This is the link from the source code of the page:
<a href="http://rapidshare.com/files/177751587/9 ... 2.rar.html" class="bbc_link new_win" target="_blank">9Dragons 2. deo</a><br />
And this is the page witch i used for testing...

I hope it helps....

Re: Php link exporter

Posted: Thu Nov 26, 2009 2:52 pm
by iankent
Can't quite see what your example pages are supposed to be doing, but it doesn't matter.

The problem is going to be somewhere in your pattern matching code (the bit that uses $stag and $etag). Copy and paste the bit that uses those two variables to find a match please?

I'd still strongly recommend you use the regex instead of the method you're attempting to use, as the regex should catch this URL easily.

Re: Php link exporter

Posted: Thu Nov 26, 2009 3:03 pm
by The_L
I would use regex but i don't know how to use it and where to get one...:/
Copy and paste the bit that uses those two variables to find a match please?
Can you be more specific?? "bit"???? :/

Re: Php link exporter

Posted: Thu Nov 26, 2009 3:10 pm
by iankent
iankent wrote:check the status.net source code yourself. you can get it at http://www.status.net/. the file you need is util.php. copy and paste the $regex line from there yourself - its easy to spot, its the only regex that big
please read my posts carefully, I've given you the regex (which admittedly doesn't seem to work when copied and pasted on the forum), but I've also told you specifically where in the status.net source code you can find exactly the regex you need. I've also given you step by step instructions on how to integrate that regex with your code and how to use it to find URLs in source HTML.

I don't mind helping but there's no point in me repeating myself over and over, so please, read through this topic carefully and if you still can't get it to work, please provide the full code you're trying to use.

Re: Php link exporter

Posted: Thu Nov 26, 2009 3:25 pm
by The_L
i followed all your instructions and still cant make it work...its just too confusing...

And here are the codes...:/

Re: Php link exporter

Posted: Thu Nov 26, 2009 3:43 pm
by iankent
Have a look at the attachment.
taggrab.rar
(2.43 KiB) Downloaded 13 times
Couple of points to note:
1. It does return some false positives. It should be simple to filter these out should you need to.
2. I've commented out your CURL code and used file_get_contents (my dev server doesn't curl installed atm)
3. I've put both the class and the main code in the same file for testing
3. I've removed the $stag and $etag variables
4. The parse_array function in your class doesn't have any parameters.
5. Matching is done only using the regex, avoiding the need to manually search the HTML for any occurances of a string

edit: there's a bug on line 23, the second <li> should be </li>

hopefully that'll give you a good starting point!

Re: Php link exporter

Posted: Thu Nov 26, 2009 3:45 pm
by The_L
Damn...i didnt understund anything xD ... So what to change/add/remove???

Re: Php link exporter

Posted: Thu Nov 26, 2009 3:46 pm
by iankent
The_L wrote:Damn...i didnt understund anything xD ... So what to change/add/remove???
if you download the example and run that PHP file, it should do pretty much what you wanted. it'll scan the result of http://www.google.co.uk/?q=test for any URLs it can find, outputting them on the page.

Re: Php link exporter

Posted: Thu Nov 26, 2009 5:04 pm
by The_L
All i see is errors...:/

Re: Php link exporter

Posted: Thu Nov 26, 2009 5:28 pm
by iankent
The_L wrote:All i see is errors...:/
Care to share what they are? It works ok for me so seeing the errors would help :)

Re: Php link exporter

Posted: Thu Nov 26, 2009 5:52 pm
by The_L
Can you upload your files?

Current errors is...
Fatal error: Using $this when not in object context in /nfs/c02/h10/mnt/30579/domains/forum-racunara.com/html/test/taggrab.class.php on line 46

Re: Php link exporter

Posted: Thu Nov 26, 2009 5:59 pm
by iankent
The_L wrote:Can you upload your files?
I already have, it was an attachment to an earlier post. I did make that clear in two separate posts.

If you use the code in my attachment then the error you've had is impossible.

If you're using the code you uploaded (http://forum-racunara.com/test/link grabber.rar) then taggrab.class.php no longer contains a class declaration, so the $this variable doesn't exist in the context of parse_array().

Re: Php link exporter

Posted: Thu Nov 26, 2009 6:17 pm
by The_L
I'm trying to make your script to work...can you just make it work and attach it? it would be so much easier than this argue...i know i'm asking much but it would end all this...