Sharing data between getSearchUrl and getDetails
#1
Hi,
I am writing an MMA scraper from sherdog.com

Is there any way I can set variable in the getSearchUrl function which I can later use in getDetails. For testing I tried:

Set buffer 7 in getSearchUrl
Code:
<RegExp input="$$4" output=" BOGUS" dest="7">
    <expression noclean="1" clear="yes"/>
</RegExp>

Append it to the title in getDetails
Code:
<RegExp input="$$1" output="&lt;title&gt;\1[$$7]&lt;/title&gt;&lt;originaltitle&gt;\1[$$7]&lt;/originaltitle&gt;&lt;year&gt;\2&lt;/year&gt;" dest="6">
    <expression trim="1" noclean="1">&lt;title&gt;([^&lt;]+)&lt;/title&gt;.*&lt;span class=&quot;date&quot;&gt;&lt;meta itemprop=&quot;startDate&quot; content=&quot;([0-9]+)</expression>
</RegExp>

But the title is just getting [] appended to it. i.e. $$7 is the empty string.

So from this can I assume that all the $$ buffers are reset for each function call. e.g. $$1 is input parameter and all others are cleared (although $$2 is apparently used by some functions - doco?).
So is there any other way I can share this data? Other variable names? Is it even possible from a threading/control flow point of view?

Background: The reason I want this is that I sometimes have 2 for an MMA event. e.g.
Code:
UFC-148.avi
UFC-148-prelims.avi
So here I want to strip the -prelims from the search URL, and then append "prelims" back into the title. The stripping is working fine. The adding back is not because the buffer I stored it in is empty.
Reply
#2
Basically, you want to add clearbuffers="no" into the function you don't want the buffers clearing after it's run.

So,
Code:
<GetSearchResults clearbuffers="no" dest="3">

(Just remember to use clear="yes" in the expression if you re-use a buffer, and don't want the old contents appearing if there's no match.)
Reply
#3
Thanks. I had to set the clearbuffers="no" on both the getSearchUrl and getSearchResults. Which made sense once I thought about it.
Its all working now, very much appreciated.
Reply

Logout Mark Read Team Forum Stats Members Help
Sharing data between getSearchUrl and getDetails0