Omnibus commited on
Commit
a4ae764
·
1 Parent(s): 489d2fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -14
app.py CHANGED
@@ -53,28 +53,20 @@ def details_fn(query):
53
  page = requests.get(f"{query}")
54
  #links = soup.findAll("a")
55
  soup = BeautifulSoup(page.content, 'html.parser')
56
- title = soup.title.string
57
  print (title)
58
- description = soup.find('meta', attrs={'name':'description'})
59
  try:
60
- print (dir(description))
61
  except Exception as e:
62
- print (e)
63
  try:
64
- print (description['content'])
 
65
  except Exception as e:
66
- print (e)
67
- try:
68
- print (description.string)
69
- except Exception as e:
70
- print (e)
71
  file = open("myfile.txt", "w")
72
  file.close()
73
  out = f"""
74
- <center>{title}<br>{description['content']}</center>"""
75
- #with open("myfile.txt", "r") as file1:
76
- # html_out = file1.read()
77
- #out = format_t(html_out)
78
  return out
79
 
80
  def first():
 
53
  page = requests.get(f"{query}")
54
  #links = soup.findAll("a")
55
  soup = BeautifulSoup(page.content, 'html.parser')
 
56
  print (title)
 
57
  try:
58
+ title = soup.title.string
59
  except Exception as e:
60
+ title = query
61
  try:
62
+ description = soup.find('meta', attrs={'name':'description'})
63
+ description = description['content']
64
  except Exception as e:
65
+ description = title
 
 
 
 
66
  file = open("myfile.txt", "w")
67
  file.close()
68
  out = f"""
69
+ <center><h3>{title}</h3><br>{description['content']}</center>"""
 
 
 
70
  return out
71
 
72
  def first():