0x376h commited on
Commit
538ada5
1 Parent(s): d25f10a
Files changed (2) hide show
  1. app.py +49 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import json
3
+ import re
4
+ import gradio as gr
5
+ import cloudscraper
6
+ scraper = cloudscraper.create_scraper()
7
+
8
+ def getlivejson(url):
9
+ pattern = re.compile(r'show/(.*)')
10
+ numbers = pattern.findall(url)
11
+ infoid =numbers[0]
12
+ purl="https://weibo.com/l/!/2/wblive/room/show_pc_live.json?live_id=" + infoid
13
+ headers = {
14
+ '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',
15
+ 'Accept':'application/json, text/plain, */*',
16
+ 'Referer':url
17
+ }
18
+ response = requests.get(purl, headers=headers)
19
+ retinfo= json.loads(response.text)
20
+ return retinfo["data"]["replay_origin_url"]
21
+
22
+ def getyoujiaurl(url):
23
+ 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;'
24
+ headers = {
25
+ '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',
26
+ 'Accept':'application/json, text/plain, */*',
27
+ 'Cookie':cookie
28
+ }
29
+ response = requests.get(url, headers=headers)
30
+ return response.text
31
+
32
+ def getcloudscraper(url):
33
+ response=scraper.get("https://community.cloudflare.com/t/attention-required-cloudflare/229679").text
34
+ return response
35
+
36
+ demo = gr.Interface(
37
+ fn=getcloudscraper,
38
+ inputs="text",
39
+ outputs="text",
40
+ )
41
+
42
+ demo.launch()
43
+
44
+
45
+ # url="https://weibo.com/l/wblive/p/show/1022:2321325026359016816923"
46
+ # info=getlivejson(url)
47
+ # print(info)
48
+
49
+
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ cloudscraper