[advanced search]
Results from the most recent live auction are here.
15 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming > CODE
User Name
Password

Old 07-29-2007, 12:17 PM   · #1
Barrucadu
Formally Mikor.
 
Barrucadu's Avatar
 
Name: Michael Walker
Location: East Yorkshire, England
Trader Rating: (7)
Join Date: Aug 2005
Posts: 2,437
NP$: 93.25 (Donate)
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
Get all links from a page

This code will get all links from a page, example. I developed it as part of a simple spider i'm working on.

This is what i'm using it for, obviously it's not finished, but I think its a pretty good (if strange) idea. Needs JavaScript. Only tested in Opera.

PHP Code:
<pre><?php

$url
= $_GET['url'];
$html = file_get_contents($url);
$preg = array();
$base = array();
$links = array();
$parsed = parse_url($url);

preg_match_all("/\<a(\s*)href(\s*)=(\s*)\"(.*?)\"(.*?)\>(.*?)\<\/a\>/i", $html, $preg[0]);
preg_match_all("/\<a(\s*)href(\s*)=(\s*)'(.*?)'(.*?)\>(.*?)\<\/a\>/i", $html, $preg[1]);
preg_match("/\<base(\s*)href(\s*)=(\s*)\"(.*?)\"(\s*)\/\>/i", $html, $base);

$title = array_merge($preg[0][6], $preg[1][6]);
$href = array_merge($preg[0][4], $preg[1][4]);
$base = $base[4];

if(empty(
$base))
    
$base = (!empty($parsed['user'])) ? "{$parsed['scheme']}://{$parsed['user']}:{$parsed['pass']}@{$parsed['host']}" : "{$parsed['scheme']}://{$parsed['host']}";

for(
$i = 0; $i < count($href); $i ++){
    if(
substr($href[$i], 0, 1) == '/')
        
$href[$i] = "{$base}{$href[$i]}";
    if(
substr($href[$i], 0, 1) == '?' || substr($href[$i], 0, 1) == '#')
        
$href[$i] = "{$url}{$href[$i]}";
    
$links[$i] = array("title" => htmlentities($title[$i]), "url" => htmlentities($href[$i]));
}

print_r($links);

?></pre>


Please register or log-in into NamePros to hide ads
__________________
Me | Blog | Last.fm | F@h

archlinux User

Last edited by Mikor : 07-29-2007 at 02:23 PM.
Barrucadu is offline   Reply With Quote
Old 08-04-2007, 10:13 AM   · #2
Daniel
Danltn.com
 
Daniel's Avatar
 
Name: Daniel Neville
Location: Danltn.com / Nottingham, UK
Trader Rating: (65)
Join Date: May 2007
Posts: 1,185
NP$: 681.56 (Donate)
Daniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond repute
Ethan Allen Fund Ethan Allen Fund
I like it!

Very good potential on this script, thanks for posting.

You don't suppose you could post/zip the other files, .css, .js (although I think it's inline), and .php - We could of course source them, but it's polite to ask.

Thanks,

Dan
Daniel is offline   Reply With Quote
Old 08-05-2007, 03:45 PM   · #3
Joseph
Senior Member
 
Joseph's Avatar
 
Location: Ireland
Trader Rating: (120)
Join Date: Dec 2004
Posts: 2,458
NP$: 618.50 (Donate)
Joseph has a brilliant futureJoseph has a brilliant futureJoseph has a brilliant futureJoseph has a brilliant futureJoseph has a brilliant futureJoseph has a brilliant futureJoseph has a brilliant futureJoseph has a brilliant futureJoseph has a brilliant futureJoseph has a brilliant futureJoseph has a brilliant future
Animal Cruelty 9/11/01 :: Never Forget Find Marrow Donors! Save The Children Save The Children Save The Children Ethan Allen Fund Baby Health Child Abuse Cancer AIDS/HIV Autism Autism Lou Gehrig's Disease (ALS) Parkinson's Disease Alzheimer's Cancer Save a Life Cancer Cancer
Thanks

Repped
__________________
Quote:
- Don't learn the tricks of the trade, learn the trade

Joseph is offline   Reply With Quote
Old 08-05-2007, 11:07 PM   · #4
Barrucadu
Formally Mikor.
 
Barrucadu's Avatar
 
Name: Michael Walker
Location: East Yorkshire, England
Trader Rating: (7)
Join Date: Aug 2005
Posts: 2,437
NP$: 93.25 (Donate)
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
Here you go, make sure to set the url it will be hosted at in class.php
http://mikor.clearlyhosted.org/spider/zipped.rar
__________________
Me | Blog | Last.fm | F@h

archlinux User
Barrucadu is offline   Reply With Quote
Old 08-06-2007, 11:54 AM   · #5
Daniel
Danltn.com
 
Daniel's Avatar
 
Name: Daniel Neville
Location: Danltn.com / Nottingham, UK
Trader Rating: (65)
Join Date: May 2007
Posts: 1,185
NP$: 681.56 (Donate)
Daniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond repute
Ethan Allen Fund Ethan Allen Fund
Is this Open Source, unrestricted code? I have a commercial use of this, I can send you a finished script with Resell Rights in exchange for full reseller rights usage of the code.

Thanks,

Dan.

(P.S. Please don't say no )
Daniel is offline   Reply With Quote
Old 08-06-2007, 02:22 PM   · #6
Barrucadu
Formally Mikor.
 
Barrucadu's Avatar
 
Name: Michael Walker
Location: East Yorkshire, England
Trader Rating: (7)
Join Date: Aug 2005
Posts: 2,437
NP$: 93.25 (Donate)
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
Originally Posted by Danltn
Is this Open Source, unrestricted code? I have a commercial use of this, I can send you a finished script with Resell Rights in exchange for full reseller rights usage of the code.

Thanks,

Dan.

(P.S. Please don't say no )



Of course.
__________________
Me | Blog | Last.fm | F@h

archlinux User
Barrucadu is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


Site Sponsors
http://www.dnfinder.com Thousand Dollar Profits
Advertise your business at NamePros
All times are GMT -7. The time now is 09:16 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0