Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 602 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Get Element Attribute with cURL (PHP)

Thread title: Get Element Attribute with cURL (PHP)
Reply    
    Thread tools Search this thread Display Modes  
06-02-2010, 03:36 AM
#1
JasonGDX is offline JasonGDX
JasonGDX's Avatar
Status: Junior Member
Join date: Nov 2006
Location: Pennsylvania, USA
Expertise: Design, HTML, CSS, PHP, MySQL
Software: Photoshop, Coda
 
Posts: 95
iTrader: 4 / 100%
 

JasonGDX is on a distinguished road

  Old  Get Element Attribute with cURL (PHP)

I don't know much about cURL, but I am pretty sure that is what I would use to accomplish this. I need some help here.

I want to get the value of an attribute from a specific element on an HTML page.

This is the code:

Code:
<a href="http://www.example.com" class="lb_link right" id="linkSkip">Skip This Page ></a>
I want to get the link url from the <a> element with the id of "linkSkip" and put that in a variable.

Could anyone help with this?

Reply With Quote
06-02-2010, 12:29 PM
#2
cableguy is offline cableguy
Status: Member
Join date: Mar 2010
Location:
Expertise:
Software:
 
Posts: 156
iTrader: -1 / 0%
 

cableguy is an unknown quantity at this point

  Old

you can use this >> http://simplehtmldom.sourceforge.net/index.htm

here's the manual with an example that matches yours >> http://simplehtmldom.sourceforge.net/manual.htm

Reply With Quote
06-02-2010, 03:31 PM
#3
JasonGDX is offline JasonGDX
JasonGDX's Avatar
Status: Junior Member
Join date: Nov 2006
Location: Pennsylvania, USA
Expertise: Design, HTML, CSS, PHP, MySQL
Software: Photoshop, Coda
 
Posts: 95
iTrader: 4 / 100%
 

JasonGDX is on a distinguished road

  Old

Originally Posted by cableguy View Post
you can use this >> http://simplehtmldom.sourceforge.net/index.htm

here's the manual with an example that matches yours >> http://simplehtmldom.sourceforge.net/manual.htm
Thanks! I'll take a look at that.

I was hoping to do it in a few lines of code without a class, though. This is for a simple phpBB mod to combat a certain type of spam (linkbucks) that is used frequently on a forum I visit. Just want to visit one page, grab this link, and return it. I'm afraid all of this is overkill just for that one technique.

I'll go through the code for this though and see if I can use some of it.

Reply With Quote
06-02-2010, 10:15 PM
#4
Gaz is offline Gaz
Gaz's Avatar
Status: Request a custom title
Join date: Apr 2007
Location: UK
Expertise: Code & Programming
Software: Coda, TextMate, Sublime 2
 
Posts: 2,097
iTrader: 26 / 100%
 

Gaz will become famous soon enough Gaz will become famous soon enough

Send a message via Skype™ to Gaz

  Old

You could alternatively use preg_match (et al.) with regex if you are not wanting a full class..

Reply With Quote
06-03-2010, 12:56 AM
#5
Immersion is offline Immersion
Status: Senior Member
Join date: Dec 2005
Location:
Expertise:
Software:
 
Posts: 918
iTrader: 5 / 100%
 

Immersion is on a distinguished road

  Old

<a\b[^>]*>(.*?)</a>

or

<a href="(.*?)">

If you dont want the content and end tag.

Should return the all the links.... Then where you go from there im not sure. Either another regex to get id and href or something.

Reply With Quote
03-07-2011, 03:17 PM
#6
AvisSpevak is offline AvisSpevak
Status: I'm new around here
Join date: Mar 2011
Location: Peru
Expertise: SEO
Software: Office
 
Posts: 1
iTrader: 0 / 0%
 

AvisSpevak is on a distinguished road

  Old

regex?

Reply With Quote
03-07-2011, 09:17 PM
#7
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

Originally Posted by AvisSpevak View Post
regex ?
To find out, see http://lmgtfy.com/?q=regex

Reply With Quote
Reply    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed