Object WebTools

  • All Implemented Interfaces:

    
    public class WebTools
    
                        

    A utility object that provides tools for web-related tasks, such as evaluating JavaScript, decoding packed functions, and retrieving HTML content or cookies from web pages.

    This object relies on an internal WebView to process web content.

    • Constructor Detail

    • Method Detail

      • unpackLink

         final String unpackLink(String link, Map<String, String> headers, Function1<List<String>, String> packedSelector)

        Search packed functions in the link html and decode ONE defined by packedSelector, by default the first packed found will be decoded. Packed functions will be searched using this regex: eval\((function\(p,a,c,k,e,?\[dr]?\)..split\('\|'\).)\)

        Parameters:
        link - The link used to search the packed functions
        headers - Optional additional headers
        packedSelector - Selects a single packed code from the list
        Returns:

        The decoded packed function selected by packedSelector

      • unpackLinkAll

         final List<String> unpackLinkAll(String link, Map<String, String> headers)

        Search packed functions in the link html and decode all. Packed functions will be searched using this regex: eval\((function\(p,a,c,k,e,?\[dr]?\)..split\('\|'\).)\)

        Parameters:
        link - The link used to search the packed functions
        headers - Optional additional headers
        Returns:

        The decoded packed functions found in the link

      • unpack

         final String unpack(String packedCode)

        Decode a single packed function

        Parameters:
        packedCode - The packed function to be decoded
        Returns:

        The decoded packed function

      • unpackAll

         final List<String> unpackAll(List<String> packedCodes)

        Decode multiple packed functions

        Parameters:
        packedCodes - The packed functions to be decoded
        Returns:

        A list with the decoded functions in the same order as packedCodes

      • evalOnFinish

         final String evalOnFinish(String link, String js, String userAgent, Map<String, String> headers, Long timeout)

        Eval a js code after loading a link

        Parameters:
        link - Link to be loaded in the webview
        userAgent - Optional user agent to be used while loading the link
        headers - Optional additional headers
        timeout - Time to wait after onPageFinished is called before evaluating the code
        Returns:

        The result of the eval code

      • getHtml

         final String getHtml(String link, String userAgent, Map<String, String> headers, Long timeout)

        Get the html of the link after being loaded in a Webview

        Parameters:
        link - Link to be loaded in the webview
        userAgent - Optional user agent to be used while loading the link
        headers - Optional additional headers
        timeout - Time to wait after onPageFinished is called before getting the html
        Returns:

        The html of the link

      • getCookies

         final String getCookies(String link, String userAgent, Map<String, String> headers, Long timeout)

        Get the cookies of the link after being loaded in a Webview

        Parameters:
        link - Link to be loaded in the webview
        userAgent - Optional user agent to be used while loading the link
        headers - Optional additional headers
        timeout - Time to wait after onPageFinished is called before getting the cookies
        Returns:

        The cookies of the link

      • evalJS

         final String evalJS(String code)

        Eval js on a webview

        Parameters:
        code - Code to eval
        Returns:

        The result of the eval code