I'm building a scraper with phantom/casper.
At this point, I need to extract a URL that appears in the page only inside a js script.
Example of the page source code :
<script>
queueRequest('URL.aspx?var1='+VAR1+'&var2='+VAR2, getPageMenu');
</script>
I have no problem evaluating VAR1 and VAR2, as they are in the page context, but I need URL, which is hardcoded and has no reference to it. URL is of course different according to the page I'm on and I have no way of guessing it. Any ideas?
My ideas :
As the URL is called on page load to fill a div wih AJAX, I was thinking of maybe capturing the XHR request, but I don't know how.
I managed to get the script elem I need, using
document.getElementsByTagName('script'). That may be one way to go, but how do I get only the line I need out of 200+ lines? (the one starting withqueueRequest)
SO to make my question clear :
Which idea is better, 1 or 2?
if 1 : How do I capture the request URL with casper?
if 2 : How do I get the right line in my script?