regex for preg_match_all() for scraping specific URL cases
I need to parse HTML to extract an array of URLs like:
<a href="/article/Social-Security-Disability-Why-Should-I-Hire-an-Attorney/3702266/"
What I'd l开发者_StackOverflowike out of it is an array like:
- [0] = /article/Social-Security-Disability-Why-Should-I-Hire-an-Attorney/3702266/
- [1] = /article/Social-Security-Disability-And-Fibromyalgia/3960799/
- [2] = /article/Social-Security-Disability-Appeals-Why-You-Need-An-Advocate-At-Your-Hearing/4961868/
I'm hoping to do it in regex, but any method that actually works is fine.
Any help would be much appreciated!
please try and have a look at $result
preg_match_all('/<a href="([^"]*)"/', $urls, $result);
精彩评论