Compare commits

...

7 Commits

Author SHA1 Message Date
5b4ae05582 Merge pull request 'scraper_functions' (#1) from scraper_functions into master
Reviewed-on: #1
2024-02-06 01:24:57 +00:00
9c76ea38ce Merge branch 'master' into scraper_functions
Merged master,resolved conflicts
2024-02-06 02:22:44 +01:00
79f9c3ec02 Resolvedconflicts 2024-02-06 02:22:34 +01:00
834934fccd Added scraper function 2024-02-06 02:21:53 +01:00
252a7fbdba Merge branch 'master' of ssh://gitea.dmz.rs:2222/Decentrala/chatbot
Conflicts resolved
2024-02-06 02:08:13 +01:00
70b2c9e322 Resolvedconflicts 2024-02-06 02:08:08 +01:00
e89201cb4b Added scraper functions (wikipedia,for now) 2024-02-06 02:04:47 +01:00
3 changed files with 15 additions and 3 deletions

View File

@ -1,10 +1,11 @@
import ollama
import scraper_functions as sf
def processmsg(msg, rcpt):
if msg.startswith("!"):
return command(msg, rcpt)
elif "youtube.com/watch" in msg:
if "youtube.com/watch" in msg:
return msg.replace("youtube.com", "iv.datura.network")
elif msg.startswith("!wiki"):
return sf.query_external_website("https://en.wikipedia.org/wiki/", msg.split(" ")[1])
elif "good bot" in msg:
return "^_^"

View File

@ -1,2 +1,4 @@
slixmpp
ollama
requests
beautifulsoup4

9
scraper_functions.py Normal file
View File

@ -0,0 +1,9 @@
import requests
from bs4 import BeautifulSoup
def query_external_website(base_url, query):
page = requests.get(base_url + query)
soup = BeautifulSoup(page.content, "html.parser")
title = soup.find("span", class_="mw-page-title-main").text
content = soup.find(id="mw-content-text").select("p")[2].text
return "\nTITLE:\n" + title + "\n\nCONTENT:\n" + content + "\n\nFULL LINK:\n" + base_url + query