php - Proper XPath Syntax -
i'm trying access attribute of previous sibling, it's proving difficult.
so web page i'm trying scrape terrible , anchor tags use crappy onclick instead of href. stupid, know. i'm trying first find anchor tag containing onclick window.open('servletlinkjunkhere...'), move previous sibling, img tag, , extract src attribute it.
<img src="images/warning.gif" alt="blah blah blah" style="position:relative;top:2px;cursor:help;"> <a href="#" onclick="javascript:window.open('servletlinkjunkhere...')> and here's xpath i'm trying use:
$url_pre = 'a[onclick*="'servletlinkjunkhere...'"]/preceding-sibling::img/@src'; any ideas on how can accomplish this? know it's possible, i'm not totally proficient in xpath queries. also, there resources learning nooks , crannies of xpath? thanks!
edit: have doesn't seem returning empty array.
$url_email = "editnotificationinfoservlet?cb=on&id=" . $id . "&sessionid=1"; $url_pre = "a[contains(@onclick,'" . $url_email . "')]/preceding-sibling::img/@src"; $final_text = $crawler->filterxpath($url_pre)->each(function($crawler, $i) { return $crawler->text(); });
i think need use following xpath:
a[contains(@onclick,'servletlinkjunkhere...')]/preceding-sibling::img/@src
Comments
Post a Comment