This forum is in read-only mode. The new forum is live at and registrations are open!

How to capture HTTP headers properly?

  • What's the best way to capture HTTP <h1> or <h2> headers?
    I mean something like this:

    <h2>Bandwidth Usage</h2>
    0 GB /

    Doing an LR includes <span> in the capture as well (I know I can replace it in a Function block, but that's too many unnecessary blocks). So what's the most efficient way to capture this?

  • Donator

    regex or you can use css

  • Can you please provide an example?

    I've done something like this before with CSS:

    Selector: [name=token]
    Attribute: value

    But I don't know how to use it in this case.

  • Donator

    im not an expert with regex or css i would need the complete source code to trial and error 😄

  • Well, I've provided an example in my first post. How would you capture that?

  • if done in regex you could use <h2>Bandwidth Usage<\/h2>\n<span>\n(.*\n.*)<\/span> and group 1 should capture it but css is easier in chrome you can just copy innerHTML or outerHTML depending what you need

  • @cass
    I want to capture what is inside <span> like so:
    x GB / Unlimited
    How would I use CSS here? What should I exactly use for Selector and Attribute?

  • Admin

    Open it with chrome, right click inspect element, highlight the span element you want to capture and right click -> copy -> selector. Paste it in OB and as attribute to capture you can put innerHTML. This procedure works in 90% of cases.

  • Thank you so much. It's much better now, however I get something like this:
    x GB /
    Is it possible to get rid of the unnecessary line break?

  • Admin

    Function block -> Replace -> Maybe Tick regex idk -> Replace \r\n or \n with nothing (see which one works)

  • Regexing \n works perfectly.
    I was trying to figure out a way to do it in a single block of parsing. I see that there's an option to use regex in combination with LR but not CSS. Any particular reason for lack of regex in CSS mode?

  • Admin

    CSS Selector and Regex are 2 different ways of parsing stuff, so it makes no sense to do it in a single block... the only way to use a single block is to use regex from the beginning, but i don't have the time to write you the pattern now, and i would need the entire page source code anyways

  • I know, but I was wondering maybe they could be used together like LR and regex to reduce the number of blocks. But I guess adding an extra Replace function won't use much resources.
    I wouldn't presume to bother you like that since I can write it with trial and error, besides I'm not looking for ready answers but directions. At any rate I was deliberately avoiding regex altogether since as you've stated in the other thread it's slow.
    I think I've achieved what I wanted with the things I've learned here. Thank you all.

Log in to reply