|
import requests |
|
import json |
|
import re |
|
import gradio as gr |
|
import cloudscraper |
|
scraper = cloudscraper.create_scraper() |
|
|
|
def getlivejson(url): |
|
pattern = re.compile(r'show/(.*)') |
|
numbers = pattern.findall(url) |
|
infoid =numbers[0] |
|
purl="https://weibo.com/l/!/2/wblive/room/show_pc_live.json?live_id=" + infoid |
|
headers = { |
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36', |
|
'Accept':'application/json, text/plain, */*', |
|
'Referer':url |
|
} |
|
response = requests.get(purl, headers=headers) |
|
retinfo= json.loads(response.text) |
|
return retinfo["data"]["replay_origin_url"] |
|
|
|
def getyoujiaurl(url): |
|
cookie='BDUSS=1; BAIDUID=4; CITY=%7B%22code%22%3A%22131%22%2C%22name%22%3A%22%E5%8C%97%E4%BA%AC%22%7D; MAWEBCUID=2; YOUJIAID=3:FG=1;' |
|
headers = { |
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36', |
|
'Accept':'application/json, text/plain, */*', |
|
'Cookie':cookie |
|
} |
|
response = requests.get(url, headers=headers) |
|
return response.text |
|
|
|
def getcloudscraper(url): |
|
response=scraper.get(url).text |
|
return response |
|
|
|
demo = gr.Interface( |
|
fn=getcloudscraper, |
|
inputs="text", |
|
outputs="text", |
|
) |
|
|
|
demo.launch() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|