2

(I have to deal with this awful vendor site made for IE6)

I'm trying to find a way to dig out a link.

ex: <a href="/part/id.aspx?v=449530">, no matter where it may appear.

Basically, the first <a> beginning with /part/id.aspx?v=.

And extract the '449530'. There are no usable id's, classes, or anything, and the whole thing isn't valid HTML, XHTML, or XML.

Been going at it with http://simplehtmldom.sourceforge.net to not much avail.

Any help is very much aprpeciated.

hakre
  • 184,866
  • 48
  • 414
  • 792
jmoon
  • 606
  • 2
  • 7
  • 18
  • This thread will probably help: http://stackoverflow.com/questions/303956/jquery-select-a-which-href-contains-some-string – Prpl_Ppl_Etr Feb 10 '12 at 22:14

2 Answers2

1
preg_match("(/part/id\.aspx\?v=([0-9]+))",$data,$m);
$id = $m[1];

That should do it.

Niet the Dark Absol
  • 311,322
  • 76
  • 447
  • 566
0

Try using a regular expression to find the element:

href=\"\/part-id\.aspx\?v=(?<id>\d+)\"
mynameiscoffey
  • 14,174
  • 5
  • 32
  • 44