Scraping dynamic data with imacro to excell

2019-09-04 12:17发布

问题:


I want to scrape dynamic data (refreshable every 4 seconds and it's a number ) with imacro and represent that number changing along the time in excell ( or any other way ).

How can i do this ? Imacro, as further as i know can get the data but can it scrap a dynamic one .

The code is from a basketball game on Flashscore ,exactly the scores table between 2 teams :
Here is an example for a game table

<table id="parts" class="parts-first horizontal">
    <tbody>
            <tr class="odd">
                <td class="score"><span class="rb">69</span</td>
                <td class="score part"><span class="p1_home">31</span></td>
            </tr>
            <tr class="even">
                <td class="score"><span class="rb">63</span></td>
                <td class="score part"><span class="p1_away">17</span></td>
            </tr>
    </tbody>
</table>

that gives those two lines data:
69 31
63 17

回答1:

Here is the more detailed answer with a code.

TAG POS=1 TYPE=TD ATTR=CLASS:"score" EXTRACT=TXT
SET !EXTRACT EVAL("'{{!EXTRACT}}'.match(/\\d+/)[0];")
TAG POS=1 TYPE=TD ATTR=CLASS:"score part" EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=scores.csv
TAG POS=2 TYPE=TD ATTR=CLASS:"score" EXTRACT=TXT
SET !EXTRACT EVAL("'{{!EXTRACT}}'.match(/\\d+/)[0];")
TAG POS=2 TYPE=TD ATTR=CLASS:"score part" EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=scores.csv
WAIT SECONDS=4

Play this macro in loop mode (button ‘Play (Loop)’) with the max. number of loops equal to a very big integer (e.g. 99999).