| | import gradio as gr |
| | from bs4 import BeautifulSoup |
| | import requests |
| |
|
| |
|
| | def greet(link): |
| | 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'} |
| | |
| | response = requests.get(link) |
| | soup = BeautifulSoup(response.text, "html.parser") |
| | |
| |
|
| | titleSoupMeta = soup.find("meta", property="og:title") |
| | videoTitle = titleSoupMeta["content"] if titleSoupMeta else "NotFound" |
| | result = {} |
| | result["views"] = soup.find("meta", itemprop="interactionCount")['content'] |
| |
|
| | |
| | |
| | |
| | response2=response.text[response.text.find("viewCount"):].split('"')[2] |
| | |
| | |
| | |
| | |
| | |
| | |
| | ''' |
| | if soup.find(attrs={"viewCount": "3363"}) == None: |
| | viewSoupMeta = "3363" #soup.find(attrs={"class": "watch-view-count"}).text |
| | else: |
| | viewSoupMeta= soup |
| | ''' |
| | |
| |
|
| | return response2 |
| |
|
| |
|
| | iface = gr.Interface(fn=greet, inputs="text", outputs="text") |
| | iface.launch() |