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.select(".mw-page-title-main")[0] content = soup.find(id="bodyContent").select("p")[2].text return "\nTITLE: " + title.text + "\n\n" + "CONTENT:" + "\n" + content + "\n\n" + "FULL LINK:\n" + base_url + query