Compare commits
No commits in common. "9704474c2929fae0915e2690803949b7641fbc19" and "5b4ae05582b700260190f9a6114638b7d3c5e7a5" have entirely different histories.
9704474c29
...
5b4ae05582
@ -2,11 +2,8 @@ import requests
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
def query_external_website(base_url, query):
|
def query_external_website(base_url, query):
|
||||||
try:
|
|
||||||
page = requests.get(base_url + query)
|
page = requests.get(base_url + query)
|
||||||
soup = BeautifulSoup(page.content, "html.parser")
|
soup = BeautifulSoup(page.content, "html.parser")
|
||||||
title = soup.find("span", class_="mw-page-title-main").text
|
title = soup.find("span", class_="mw-page-title-main").text
|
||||||
content = soup.find(id="mw-content-text").select("p")[2].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
|
return "\nTITLE:\n" + title + "\n\nCONTENT:\n" + content + "\n\nFULL LINK:\n" + base_url + query
|
||||||
except:
|
|
||||||
return "Can't parse search result :("
|
|
||||||
|
Loading…
Reference in New Issue
Block a user