Add the url content

This commit is contained in:
Paul Gauthier 2024-05-22 21:25:34 -07:00
parent dc8ae596c3
commit 5032adf44b
2 changed files with 9 additions and 6 deletions

View file

@ -1,9 +1,9 @@
#!/usr/bin/env python #!/usr/bin/env python
import hashlib import hashlib
import re
import json import json
import os import os
import re
import sys import sys
import threading import threading
import time import time
@ -582,11 +582,14 @@ class Coder:
def check_for_urls(self, inp): def check_for_urls(self, inp):
url_pattern = re.compile( url_pattern = re.compile(
r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+' r"http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+"
) )
urls = url_pattern.findall(inp) urls = url_pattern.findall(inp)
if urls: for url in urls:
self.io.tool_output(f"Found URLs: {', '.join(urls)}") self.io.tool_output(f"Adding {url} to the chat.")
inp += "\n\n"
inp += self.commands.cmd_web(url)
return inp return inp
def keyboard_interrupt(self): def keyboard_interrupt(self):

View file

@ -69,8 +69,8 @@ class Commands:
self.scraper = Scraper(print_error=self.io.tool_error) self.scraper = Scraper(print_error=self.io.tool_error)
content = self.scraper.scrape(url) or "" content = self.scraper.scrape(url) or ""
if content: # if content:
self.io.tool_output(content) # self.io.tool_output(content)
instructions = self.scraper.get_playwright_instructions() instructions = self.scraper.get_playwright_instructions()
if instructions: if instructions: