Omnibus commited on
Commit
2987ca0
1 Parent(s): 2299f1b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -25
app.py CHANGED
@@ -270,31 +270,34 @@ def link_find(url):
270
  q=("a","p","span","content","article")
271
  for p in soup.find_all("a"):
272
  url0=p.get('href')
273
- if url0.startswith("//"):
274
- print(url0)
275
- uri1=url.split("//")[0]
276
- #uri2=url.split("//")[1]
277
- #uri3=uri2.split("/")[0]
278
- #uri=f'{uri1}//{uri3}'
279
- uri=f'{uri1}{url0}'
280
- #print(uri)
281
- elif url0.startswith("/") and not url0.startswith("//"):
282
- uri1=url.split("//")[0]
283
- uri2=url.split("//")[1]
284
- uri3=uri2.split("/")[0]
285
- uri=f'{uri1}//{uri3}'
286
- uri=f'{uri}{url0}'
287
- #print(uri)
288
- else:
289
- uri=url0
290
- node1['LINKS'].append(uri)
291
- node1['TREE'].append({"URL":uri,"TITLE":p.get('title'),"STRING":p.string,"TEXT":"","LINKS":[],"TREE":[]})
292
- node2['TREE'].append({"URL":uri,"LINKS":[],"TREE":[]})
293
- node2['LINKS'].append(uri)
294
- #node2['LINK_KEY'].append(uri_key)
295
- link_box.append(uri)
296
- #out.append({"URL":p.get('href'),"TITLE":p.get('title'),"STRING":p.string,"TEXT":"","TREE":[]})
297
-
 
 
 
298
  else:
299
  print("NO")
300
  pass
 
270
  q=("a","p","span","content","article")
271
  for p in soup.find_all("a"):
272
  url0=p.get('href')
273
+ try:
274
+ if url0.startswith("//"):
275
+ print(url0)
276
+ uri1=url.split("//")[0]
277
+ #uri2=url.split("//")[1]
278
+ #uri3=uri2.split("/")[0]
279
+ #uri=f'{uri1}//{uri3}'
280
+ uri=f'{uri1}{url0}'
281
+ #print(uri)
282
+ elif url0.startswith("/") and not url0.startswith("//"):
283
+ uri1=url.split("//")[0]
284
+ uri2=url.split("//")[1]
285
+ uri3=uri2.split("/")[0]
286
+ uri=f'{uri1}//{uri3}'
287
+ uri=f'{uri}{url0}'
288
+ #print(uri)
289
+ else:
290
+ uri=url0
291
+
292
+ node1['LINKS'].append(uri)
293
+ node1['TREE'].append({"URL":uri,"TITLE":p.get('title'),"STRING":p.string,"TEXT":"","LINKS":[],"TREE":[]})
294
+ node2['TREE'].append({"URL":uri,"LINKS":[],"TREE":[]})
295
+ node2['LINKS'].append(uri)
296
+ #node2['LINK_KEY'].append(uri_key)
297
+ link_box.append(uri)
298
+ #out.append({"URL":p.get('href'),"TITLE":p.get('title'),"STRING":p.string,"TEXT":"","TREE":[]})
299
+ except Exception as e:
300
+ print (e)
301
  else:
302
  print("NO")
303
  pass