Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ from googlesearch import search
|
|
3 |
import requests
|
4 |
from bs4 import BeautifulSoup
|
5 |
import chunk # Import the chunking function from chunk.py
|
6 |
-
import json
|
7 |
|
8 |
# Function to perform Google search and return the first link
|
9 |
def google_search(query):
|
@@ -63,17 +62,18 @@ if st.button("Search"):
|
|
63 |
# Chunk the scraped text using chunk.py
|
64 |
chunked_text = chunk.chunk_text(scraped_text)
|
65 |
|
66 |
-
# Save chunked data to a file for later use
|
67 |
-
with open("chunked_data.
|
68 |
-
|
69 |
|
70 |
st.write(f"Chunked Data for Link {i}:")
|
71 |
for chunk_part in chunked_text:
|
72 |
st.write(chunk_part)
|
73 |
|
|
|
74 |
st.download_button(
|
75 |
label="Download Chunked Webpage Content",
|
76 |
-
data="\n".join(chunked_text),
|
77 |
file_name="chunked_webpage_content.txt",
|
78 |
mime="text/plain"
|
79 |
)
|
|
|
3 |
import requests
|
4 |
from bs4 import BeautifulSoup
|
5 |
import chunk # Import the chunking function from chunk.py
|
|
|
6 |
|
7 |
# Function to perform Google search and return the first link
|
8 |
def google_search(query):
|
|
|
62 |
# Chunk the scraped text using chunk.py
|
63 |
chunked_text = chunk.chunk_text(scraped_text)
|
64 |
|
65 |
+
# Save chunked data to a .txt file for later use
|
66 |
+
with open("chunked_data.txt", "w") as f:
|
67 |
+
f.write("\n---\n".join(chunked_text)) # Separate chunks by a line break and delimiter
|
68 |
|
69 |
st.write(f"Chunked Data for Link {i}:")
|
70 |
for chunk_part in chunked_text:
|
71 |
st.write(chunk_part)
|
72 |
|
73 |
+
# Provide download button for the chunked text
|
74 |
st.download_button(
|
75 |
label="Download Chunked Webpage Content",
|
76 |
+
data="\n---\n".join(chunked_text),
|
77 |
file_name="chunked_webpage_content.txt",
|
78 |
mime="text/plain"
|
79 |
)
|