Shweta7171 commited on
Commit
d8e2c66
·
verified ·
1 Parent(s): ed3f10c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -18
app.py CHANGED
@@ -2,33 +2,19 @@
2
  import streamlit as st
3
  import utils
4
 
5
- from io import StringIO
6
- from datetime import datetime
7
-
8
  def dataframe_to_csv_download(dataframe):
9
- # Convert the DataFrame to a CSV string
10
  csv = dataframe.to_csv(index=False)
11
- csv_bytes = csv.encode('utf-8')
12
-
13
- # Create a buffer to hold the CSV string in bytes
14
- buf = StringIO()
15
- buf.write(csv)
16
- buf.seek(0)
17
-
18
- today = datetime.now().strftime("%Y-%m-%d %H:%M")
19
-
20
- # Create a download button in the Streamlit app
21
  st.download_button(
22
  label="Download CSV File",
23
- data=csv_bytes,
24
- file_name=f"ScrappedData_{today}.csv",
25
  mime="text/csv",
26
  )
27
 
28
  def main():
29
  st.title('LinkedIn Job Scraper')
30
  st.write('This app scrapes LinkedIn for job listings.')
31
- url = st.text_area("Enter the URL here..")
32
 
33
  if st.button("Get Records") and url:
34
  with st.spinner("Scraping the given URL..."):
@@ -38,7 +24,7 @@ def main():
38
  st.dataframe(scrap_df)
39
  dataframe_to_csv_download(scrap_df)
40
  else:
41
- st.write("Failed to retrieve data from the URL. Please check the URL and try again.")
42
 
43
  if __name__ == '__main__':
44
  main()
 
2
  import streamlit as st
3
  import utils
4
 
 
 
 
5
  def dataframe_to_csv_download(dataframe):
 
6
  csv = dataframe.to_csv(index=False)
 
 
 
 
 
 
 
 
 
 
7
  st.download_button(
8
  label="Download CSV File",
9
+ data=csv,
10
+ file_name="ScrappedData.csv",
11
  mime="text/csv",
12
  )
13
 
14
  def main():
15
  st.title('LinkedIn Job Scraper')
16
  st.write('This app scrapes LinkedIn for job listings.')
17
+ url = st.text_input("Enter the URL here..")
18
 
19
  if st.button("Get Records") and url:
20
  with st.spinner("Scraping the given URL..."):
 
24
  st.dataframe(scrap_df)
25
  dataframe_to_csv_download(scrap_df)
26
  else:
27
+ st.error("Failed to retrieve data from the URL. Please check the URL and try again.")
28
 
29
  if __name__ == '__main__':
30
  main()