- 
                Notifications
    
You must be signed in to change notification settings  - Fork 5.5k
 
New Components - webscraping_ai #15526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
This file was deleted.
      
      Oops, something went wrong.
      
    
  
        
          
          
            126 changes: 126 additions & 0 deletions
          
          126 
        
  components/webscraping_ai/actions/ask-question/ask-question.mjs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| import webscrapingAI from "../../webscraping_ai.app.mjs"; | ||
| import utils from "../../common/utils.mjs"; | ||
| 
     | 
||
| export default { | ||
| key: "webscraping_ai-ask-question", | ||
| name: "Ask Question about Webpage", | ||
| description: "Gets an answer to a question about a given webpage. [See the documentation](https://webscraping.ai/docs#tag/AI/operation/getQuestion)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| webscrapingAI, | ||
| targetUrl: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "targetUrl", | ||
| ], | ||
| }, | ||
| question: { | ||
| type: "string", | ||
| label: "Question", | ||
| description: "The question to ask about the given webpage. E.g. `What is the summary of this page content?`", | ||
| }, | ||
| headers: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "headers", | ||
| ], | ||
| }, | ||
| timeout: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "timeout", | ||
| ], | ||
| }, | ||
| js: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "js", | ||
| ], | ||
| }, | ||
| jsTimeout: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "jsTimeout", | ||
| ], | ||
| }, | ||
| waitFor: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "waitFor", | ||
| ], | ||
| }, | ||
| proxy: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "proxy", | ||
| ], | ||
| }, | ||
| country: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "country", | ||
| ], | ||
| }, | ||
| customProxy: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "customProxy", | ||
| ], | ||
| }, | ||
| device: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "device", | ||
| ], | ||
| }, | ||
| errorOn404: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "errorOn404", | ||
| ], | ||
| }, | ||
| errorOnRedirect: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "errorOnRedirect", | ||
| ], | ||
| }, | ||
| jsScript: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "jsScript", | ||
| ], | ||
| }, | ||
| format: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "format", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.webscrapingAI.getAnswerToQuestion({ | ||
| $, | ||
| params: { | ||
| url: this.targetUrl, | ||
| question: this.question, | ||
| headers: utils.stringifyHeaders(this.headers), | ||
| timeout: this.timeout, | ||
| js: this.js, | ||
| js_timeout: this.jsTimeout, | ||
| wait_for: this.waitFor, | ||
| proxy: this.proxy, | ||
| country: this.country, | ||
| custom_proxy: this.customProxy, | ||
| device: this.device, | ||
| error_on_404: this.errorOn404, | ||
| error_on_redirect: this.errorOnRedirect, | ||
| js_script: this.jsScript, | ||
| format: this.format, | ||
| }, | ||
| }); | ||
| $.export("$summary", "Successfully retrieved answer to question"); | ||
| return response; | ||
| }, | ||
| }; | ||
        
          
          
            127 changes: 127 additions & 0 deletions
          
          127 
        
  components/webscraping_ai/actions/scrape-website-html/scrape-website-html.mjs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| import webscrapingAI from "../../webscraping_ai.app.mjs"; | ||
| import utils from "../../common/utils.mjs"; | ||
| 
     | 
||
| export default { | ||
| key: "webscraping_ai-scrape-website-html", | ||
| name: "Scrape Website HTML", | ||
| description: "Returns the full HTML content of a webpage specified by the URL. [See the documentation](https://webscraping.ai/docs#tag/HTML/operation/getHTML):", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| webscrapingAI, | ||
| targetUrl: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "targetUrl", | ||
| ], | ||
| }, | ||
| headers: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "headers", | ||
| ], | ||
| }, | ||
| timeout: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "timeout", | ||
| ], | ||
| }, | ||
| js: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "js", | ||
| ], | ||
| }, | ||
| jsTimeout: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "jsTimeout", | ||
| ], | ||
| }, | ||
| waitFor: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "waitFor", | ||
| ], | ||
| }, | ||
| proxy: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "proxy", | ||
| ], | ||
| }, | ||
| country: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "country", | ||
| ], | ||
| }, | ||
| customProxy: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "customProxy", | ||
| ], | ||
| }, | ||
| device: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "device", | ||
| ], | ||
| }, | ||
| errorOn404: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "errorOn404", | ||
| ], | ||
| }, | ||
| errorOnRedirect: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "errorOnRedirect", | ||
| ], | ||
| }, | ||
| jsScript: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "jsScript", | ||
| ], | ||
| }, | ||
| format: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "format", | ||
| ], | ||
| }, | ||
| returnScriptResult: { | ||
| type: "boolean", | ||
| label: "Return Script Result", | ||
| description: "Return result of the custom JavaScript code (`js_script` parameter) execution on the target page (`false` by default, page HTML will be returned).", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.webscrapingAI.pageHtmlByUrl({ | ||
| $, | ||
| params: { | ||
| url: this.targetUrl, | ||
| headers: utils.stringifyHeaders(this.headers), | ||
| timeout: this.timeout, | ||
| js: this.js, | ||
| js_timeout: this.jsTimeout, | ||
| wait_for: this.waitFor, | ||
| proxy: this.proxy, | ||
| country: this.country, | ||
| custom_proxy: this.customProxy, | ||
| device: this.device, | ||
| error_on_404: this.errorOn404, | ||
| error_on_redirect: this.errorOnRedirect, | ||
| js_script: this.jsScript, | ||
| format: this.format, | ||
| return_script_result: this.returnScriptResult, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully scraped HTML of URL ${this.targetUrl}`); | ||
| return response; | ||
| }, | ||
| }; | 
        
          
          
            133 changes: 133 additions & 0 deletions
          
          133 
        
  components/webscraping_ai/actions/scrape-website-text/scrape-website-text.mjs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| import webscrapingAI from "../../webscraping_ai.app.mjs"; | ||
| import utils from "../../common/utils.mjs"; | ||
| 
     | 
||
| export default { | ||
| key: "webscraping_ai-scrape-website-text", | ||
| name: "Scrape Website Text", | ||
| description: "Returns the visible text content of a webpage specified by the URL. [See the documentation](https://webscraping.ai/docs#tag/Text/operation/getText).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| webscrapingAI, | ||
| targetUrl: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "targetUrl", | ||
| ], | ||
| }, | ||
| headers: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "headers", | ||
| ], | ||
| }, | ||
| timeout: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "timeout", | ||
| ], | ||
| }, | ||
| js: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "js", | ||
| ], | ||
| }, | ||
| jsTimeout: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "jsTimeout", | ||
| ], | ||
| }, | ||
| waitFor: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "waitFor", | ||
| ], | ||
| }, | ||
| proxy: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "proxy", | ||
| ], | ||
| }, | ||
| country: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "country", | ||
| ], | ||
| }, | ||
| customProxy: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "customProxy", | ||
| ], | ||
| }, | ||
| device: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "device", | ||
| ], | ||
| }, | ||
| errorOn404: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "errorOn404", | ||
| ], | ||
| }, | ||
| errorOnRedirect: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "errorOnRedirect", | ||
| ], | ||
| }, | ||
| jsScript: { | ||
| propDefinition: [ | ||
| webscrapingAI, | ||
| "jsScript", | ||
| ], | ||
| }, | ||
| textFormat: { | ||
| type: "string", | ||
| label: "Text Format", | ||
| description: "The format of the returned text content. Default: `json`", | ||
| options: [ | ||
| "plain", | ||
| "xml", | ||
| "json", | ||
| ], | ||
| default: "json", | ||
| optional: true, | ||
| }, | ||
| returnLinks: { | ||
| type: "boolean", | ||
| label: "Return Links", | ||
| description: "Whether to include links in the returned text content. Works only when Text Format is `json`.", | ||
| optional: true, | ||
| }, | ||
                
      
                  michelle0927 marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.webscrapingAI.pageTextByUrl({ | ||
| $, | ||
| params: { | ||
| url: this.targetUrl, | ||
| headers: utils.stringifyHeaders(this.headers), | ||
| timeout: this.timeout, | ||
| js: this.js, | ||
| js_timeout: this.jsTimeout, | ||
| wait_for: this.waitFor, | ||
| proxy: this.proxy, | ||
| country: this.country, | ||
| custom_proxy: this.customProxy, | ||
| device: this.device, | ||
| error_on_404: this.errorOn404, | ||
| error_on_redirect: this.errorOnRedirect, | ||
| js_script: this.jsScript, | ||
| text_format: this.textFormat, | ||
| return_links: this.returnLinks, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully scraped text from ${this.targetUrl}`); | ||
| return response; | ||
| }, | ||
| }; | ||
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.