Spaces:
Runtime error
Runtime error
#import gradio as gr | |
from bs4 import BeautifulSoup | |
import requests | |
#from python_actr import * | |
#from cogscidighum import * | |
#class myCelSci(Model): | |
# pass | |
def bcf(link): #add source? and for sentsummary: https://huggingface.co/themanas021 | |
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'} | |
#link = "https://youtu.be/vQUCSHUlN-k?si=FfIsODGjJDzIHOAS" | |
bcfresponse = requests.get(link) #, headers=HEADER) | |
soup = BeautifulSoup(bcfresponse.text, "html.parser") | |
#print (soup.prettify()) | |
titleSoupMeta = soup.find("meta", property="og:title") | |
videoTitle = titleSoupMeta["content"] if titleSoupMeta else "NotFound" | |
bcfresult = {} | |
bcfresult["views"] = soup.find("meta", itemprop="interactionCount")['content'] | |
#soup=soup.prettify() | |
#viewSoupMeta = [line for line in soup.split('viewCount') if "views" in line] | |
#response2=bcfresult.text[bcfresponse.text.find("viewCount"):].split('"')[2] | |
# Store JSON data in API_Data | |
#for key in API_Data:{ | |
# print(key,":", API_Data[key]) | |
#} | |
#viewSoupMeta=viewSoupMeta[19:25] | |
##videoViews = viewSoupMeta["content"] if titleSoupMeta else "NotFound" | |
''' | |
if soup.find(attrs={"viewCount": "3363"}) == None: | |
viewSoupMeta = "3363" #soup.find(attrs={"class": "watch-view-count"}).text | |
else: | |
viewSoupMeta= soup | |
''' | |
#viewSoupMeta = API_Data #str(response).find("viewCount") | |
#celsci1=myCelSci() | |
#response3= bcfresponse #celsci1.ax1 #celsci1.fame(300) #checkfame("dd") | |
return bcfresult #result #soup.prettify() |