Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 12-05-2003, 02:30 AM   #1
4Pics
Confirmed User
 
Industry Role:
Join Date: Dec 2001
Posts: 7,952
Php Help needed...

Can someone share some code that will grab from a webpage all a href's and img's on the page? Also how to grab a certain text string out of a webpage.

Thanks
4Pics is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-05-2003, 02:31 AM   #2
Alky
Confirmed User
 
Alky's Avatar
 
Join Date: Apr 2002
Location: Houston
Posts: 5,651
http://www.php.net/manual/en/function.preg-grep.php
Alky is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-05-2003, 02:32 AM   #3
Why
MFBA
 
Industry Role:
Join Date: Mar 2003
Location: PNW
Posts: 7,230
php.net is where all questions about php are answered. much better place to seek answers then GFY.
Why is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-05-2003, 02:36 AM   #4
fletcher
Confirmed User
 
Join Date: Jan 2003
Location: Austin, TX
Posts: 698
I'll be nice and share one regexp

This grabs all linked images on a page:

PHP Code:
/<a.*href=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><img.*src=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><\/a>/im 
In PHP, do it like this:

PHP Code:
preg_match_all("/<a.*href=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><img.*src=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><\/a>/im"$string$matches
$matches is an array with all of the images with links. Just change up the regexp for plain links, images, etc.
__________________
&nbsp;
[email protected]
ICQ: 6411138
fletcher is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-05-2003, 02:37 AM   #5
swedguy
Confirmed User
 
Industry Role:
Join Date: Jan 2002
Posts: 7,981
http://zend.com/codex.php?id=231&single=1
swedguy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-05-2003, 11:16 AM   #6
4Pics
Confirmed User
 
Industry Role:
Join Date: Dec 2001
Posts: 7,952
Quote:
Originally posted by fletcher
I'll be nice and share one regexp

This grabs all linked images on a page:

PHP Code:
/<a.*href=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><img.*src=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><\/a>/im 
In PHP, do it like this:

PHP Code:
preg_match_all("/<a.*href=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><img.*src=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><\/a>/im"$string$matches
$matches is an array with all of the images with links. Just change up the regexp for plain links, images, etc.
Thanks, but is your top link correct? It looks like it is cutoff?
4Pics is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.