Spaces:
Runtime error
Runtime error
CognitiveScience
commited on
Commit
·
70b37e8
1
Parent(s):
c885038
Update app.py
Browse files
app.py
CHANGED
@@ -3,38 +3,15 @@ from bs4 import BeautifulSoup
|
|
3 |
import requests
|
4 |
|
5 |
|
6 |
-
def
|
7 |
-
#HEADER = {"User-Agent": 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
|
8 |
-
#link = "https://youtu.be/vQUCSHUlN-k?si=FfIsODGjJDzIHOAS"
|
9 |
-
response = requests.get(link) #, headers=HEADER)
|
10 |
-
soup = BeautifulSoup(response.text, "html.parser")
|
11 |
-
#print (soup.prettify())
|
12 |
-
|
13 |
-
#titleSoupMeta = soup.find("meta", property="og:title")
|
14 |
-
#videoTitle = titleSoupMeta["content"] if titleSoupMeta else "NotFound"
|
15 |
-
#result = {}
|
16 |
-
#result["views"] = soup.find("meta", itemprop="interactionCount")['content']
|
17 |
|
18 |
-
|
19 |
-
|
20 |
|
21 |
bcsresult=response.text[response.text.find("viewCount"):].split('"')[2]
|
22 |
-
# Store JSON data in API_Data
|
23 |
-
#for key in API_Data:{
|
24 |
-
# print(key,":", API_Data[key])
|
25 |
-
#}
|
26 |
-
#viewSoupMeta=viewSoupMeta[19:25]
|
27 |
-
##videoViews = viewSoupMeta["content"] if titleSoupMeta else "NotFound"
|
28 |
-
'''
|
29 |
-
if soup.find(attrs={"viewCount": "3363"}) == None:
|
30 |
-
viewSoupMeta = "3363" #soup.find(attrs={"class": "watch-view-count"}).text
|
31 |
-
else:
|
32 |
-
viewSoupMeta= soup
|
33 |
-
'''
|
34 |
-
#viewSoupMeta = API_Data #str(response).find("viewCount")
|
35 |
|
36 |
return bcsresult #soup.prettify()
|
37 |
|
38 |
|
39 |
-
iface = gr.Interface(fn=
|
40 |
iface.launch()
|
|
|
3 |
import requests
|
4 |
|
5 |
|
6 |
+
def bcs(inp):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
response = requests.get(inp) #, headers=HEADER)
|
9 |
+
soup = BeautifulSoup(response.text, "html.parser")
|
10 |
|
11 |
bcsresult=response.text[response.text.find("viewCount"):].split('"')[2]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
return bcsresult #soup.prettify()
|
14 |
|
15 |
|
16 |
+
iface = gr.Interface(fn=bcs, inputs="text", outputs="text")
|
17 |
iface.launch()
|