Examples - NanoDankster/Skraper GitHub Wiki

You can send me a direct message on Discord (Nano#1334) for your examples!


Example 1
command /skraper <text>:
    trigger:
        set {_query} to arg-1
        set {_url} to "https://www.youtube.com/results?search_query=%{_query}%"
        set {_agent} to "Mozilla/5.0"
        set {_timeout} to 10000
        set {_referer} to "https://www.google.com"
        request document from {_url} with user agent {_agent} and timeout {_timeout} and referrer {_referer}
        set {_doc} to last received document
        send {_doc}
Example 2
command skraper:
    trigger:
        # Set the URL
        set {_url} to "https://nanodankster.github.io/"
        
        # Set the user agent to get the data
        set {_agent} to "Mozilla/5.0"
        
        # Timeout is required for the scraper
        set {_timeout} to 10000
        
        # Referrer is required for the scraper
        set {_referrer} to "https://www.google.com"
        
        # Send the request
        request document from {_url} with user agent {_agent} and timeout {_timeout} and referrer {_referrer}
        
        # Set the variable to the requested document
        set {_doc} to last received document
        
        # Get the title of the document
        send "Title: %title of {_doc}%"
        

        
        # Counter for "li" tags
        set {_i} to 0
        
        # Use the CSS selector to find the tag
        loop elements "li" of {_doc}:
        
            # Send the tag name and the text of the element
            send "%tag name of loop-value%: %html text of loop-value%" 
            
            add 1 to {_i}
            
        # Send the counter for "li" tags
        send "Found %{_i}% of ""li"""
        

        
        # Counter for "h3" tags
        set {_i} to 0
        
        # Use the CSS selector to find the tag
        loop elements "h3" of {_doc}:
            
            # Send the tag name and the text of the element
            send "%tag name of loop-value%: %html text of loop-value%"
            
            add 1 to {_i}
            
        # Send the counter for "h3" tags
        send "Found %{_i}% of ""h3"""
⚠️ **GitHub.com Fallback** ⚠️