Spaces:
Runtime error
Runtime error
CognitiveScience
commited on
Commit
•
88f2e7d
1
Parent(s):
6511820
Create ccogsphere.py
Browse files- ccogsphere.py +17 -0
ccogsphere.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from bs4 import BeautifulSoup
|
2 |
+
import requests
|
3 |
+
|
4 |
+
def ccs(inp):
|
5 |
+
inp1=inp.split(":")
|
6 |
+
if (inp1[0]=="https"):
|
7 |
+
response = requests.get(inp)
|
8 |
+
soup = BeautifulSoup(response.text, "html.parser")
|
9 |
+
result=response.text[response.text.find("viewCount"):].split('"')[2]
|
10 |
+
else:
|
11 |
+
try:
|
12 |
+
result=inp1[0] + " Picked " + inp1[1]
|
13 |
+
except NameError:
|
14 |
+
result="Bad Format" #inp1[0] + " Picked " + inp1[1] + "\n"
|
15 |
+
|
16 |
+
|
17 |
+
return result
|