How to parse content in html?



  • Hello guys, I just started with OB, I want to capture the following 2 contents:
    September 7th 2020
    and
    0 /
    10 GB
    I have it tested with https://openbullet.dev/regex/
    to use regex but they don't work or I do it wrong. Please help me. Thanks very much!
    Below is the response content from Source in html:

    <!DOCTYPE html>
    <div class="ma_item">
    <h2>Next Reset</h2>
    <span>September 7th 2020</span>
    </div>
    <div class="ma_item">
    <h2>Bandwidth Usage</h2>
    <span>
    0 /
    10 GB</span>
    </div>



  • First you create two "Parse" blocks and set their mode to "REGEX"

    1. Now to capture <Date>, in the "Regex" field of first parse type the following:
    <h2>Next Reset<\/h2>\s+<span>(.*?)<\/span>
    

    and set the "Output" field to:

    [1]
    

    1. Also to capture the <Usage>, type the following in the "Regex" field of second parse:
    <h2>Bandwidth Usage<\/h2>\s+<span>\s+(.*)\s+(.*?)<\/span>
    

    and set the "Output" field to:

    [1] [2]
    


  • @masterchief said in How to parse content in html?:

    First you create two "Parse" blocks and set their mode to "REGEX"

    1. Now to capture <Date>, in the "Regex" field of first parse type the following:
    <h2>Next Reset<\/h2>\s+<span>(.*?)<\/span>
    

    and set the "Output" field to:

    [1]
    

    1. Also to capture the <Usage>, type the following in the "Regex" field of second parse:
    <h2>Bandwidth Usage<\/h2>\s+<span>\s+(.*)\s+(.*?)<\/span>
    

    and set the "Output" field to:

    [1] [2]
    

    Thank you very much. I followed and it worked fine. Great!
    9f62c71b-dc1c-4eef-a3e9-2d04baffc387-image.png


Log in to reply