-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddb8ff7
commit d9f27f7
Showing
6 changed files
with
41 additions
and
69 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains 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,9 @@ | ||
import requests | ||
from bs4 import BeautifulSoup | ||
|
||
def gather(keyword): | ||
url = "https://en.wikipedia.org/wiki/" + keyword | ||
response = requests.get(url) | ||
soup = BeautifulSoup(response.content, "html.parser") | ||
details = soup.find_all('table', {'class': 'infobox'}) | ||
return details, soup('p')[:2] |
This file contains 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,32 @@ | ||
import streamlit as st | ||
from gather import gather | ||
|
||
def main(): | ||
st.markdown( | ||
'<div style="text-align:center"><img src="https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExMDlhMDN3MncyZWRkemh5b2h0cmI2bWUwaTN3MmZkaTJ6cWJtZGxvNyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/1QGRJ9cOTbh5K/giphy.gif" width="500" height="150"></div>', | ||
unsafe_allow_html=True | ||
) | ||
st.markdown('<h1 style="text-align: center;">InFo_hUnT</h1>', unsafe_allow_html=True) | ||
input_data = st.text_input("Enter your word") | ||
if input_data: | ||
keyword = "_".join(input_data.strip().split()) | ||
details, paragraphs = gather(keyword) | ||
|
||
if details: | ||
st.write("### Structured Data '{}'".format(input_data)) | ||
for detail in details: | ||
rows = detail.find_all('tr') | ||
for row in rows: | ||
heading = row.find('th') | ||
detail = row.find('td') | ||
if heading and detail: | ||
st.write("**{}:** {}".format(heading.text.strip(), detail.text.strip())) | ||
else: | ||
st.write(" Stuctured data not yet available for '{}'".format(input_data)) | ||
|
||
st.write("### Summary for '{}'".format(input_data)) | ||
for paragraph in paragraphs: | ||
st.write(paragraph.text.strip()) | ||
|
||
if __name__ == "__main__": | ||
main() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.