Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
import urllib.request
|
| 3 |
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36'}
|
| 4 |
def getHtml(url):
|
|
@@ -10,8 +10,8 @@ def saveHtml(file_name, file_content):
|
|
| 10 |
with open(file_name.replace('/', '_') + ".html", "wb") as f:
|
| 11 |
f.write(file_content)
|
| 12 |
usr_name_list=['NikaLegran']
|
| 13 |
-
|
| 14 |
-
usr_name_list=bytes.decode(f1.read()).split(' ')
|
| 15 |
#print(usr_name_list[:10])
|
| 16 |
for i in range(len(usr_name_list)):
|
| 17 |
#url = "http://www.view.sdu.edu.cn/info/1003/75240.htm"
|
|
@@ -26,4 +26,64 @@ def greet(name):
|
|
| 26 |
return "Hello " + name + "!!"
|
| 27 |
|
| 28 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 29 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'''import gradio as gr
|
| 2 |
import urllib.request
|
| 3 |
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36'}
|
| 4 |
def getHtml(url):
|
|
|
|
| 10 |
with open(file_name.replace('/', '_') + ".html", "wb") as f:
|
| 11 |
f.write(file_content)
|
| 12 |
usr_name_list=['NikaLegran']
|
| 13 |
+
with open('user.txt','rb') as f1:
|
| 14 |
+
usr_name_list=bytes.decode(f1.read()).split(' ')
|
| 15 |
#print(usr_name_list[:10])
|
| 16 |
for i in range(len(usr_name_list)):
|
| 17 |
#url = "http://www.view.sdu.edu.cn/info/1003/75240.htm"
|
|
|
|
| 26 |
return "Hello " + name + "!!"
|
| 27 |
|
| 28 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 29 |
+
iface.launch()'''
|
| 30 |
+
from selenium import webdriver
|
| 31 |
+
import time
|
| 32 |
+
from msedge.selenium_tools import EdgeOptions
|
| 33 |
+
from msedge.selenium_tools import Edge
|
| 34 |
+
edge_options = EdgeOptions()
|
| 35 |
+
edge_options.use_chromium = True
|
| 36 |
+
# 设置无界面模式,也可以添加其它设置
|
| 37 |
+
edge_options.add_argument('headless')
|
| 38 |
+
driver=Edge(options=edge_options)
|
| 39 |
+
usr_name_list=['NikaLegran']
|
| 40 |
+
with open('user.txt','rb') as f1:
|
| 41 |
+
usr_name_list=bytes.decode(f1.read()).split(' ')
|
| 42 |
+
print(usr_name_list[:10])
|
| 43 |
+
earned_list=[]
|
| 44 |
+
def get_profile(usr_name,rt='F:/model_profile/'):
|
| 45 |
+
get_html = rt+usr_name+".html"
|
| 46 |
+
#打开文件,准备写入
|
| 47 |
+
f = open(get_html,'wb')
|
| 48 |
+
url = 'https://zh.stripchat.com/'+usr_name+'/profile' # 这里填你要保存的网页的网址
|
| 49 |
+
driver.get(url)
|
| 50 |
+
time.sleep(0.9) # 保证浏览器响应成功后再进行下一步操作
|
| 51 |
+
#写入文件
|
| 52 |
+
f.write(driver.page_source.encode("utf-8", "ignore"))
|
| 53 |
+
f.close()
|
| 54 |
+
|
| 55 |
+
def cal_earned(usr_name,rt='F:/model_profile/'):
|
| 56 |
+
|
| 57 |
+
#get_profile(usr_name,'./')
|
| 58 |
+
f=open(rt+usr_name+'.html','rb')
|
| 59 |
+
data=bytes.decode(f.read())
|
| 60 |
+
Len_pre=len('"achieved-epic-goals__tokens">')
|
| 61 |
+
tot=0
|
| 62 |
+
ok=False
|
| 63 |
+
for i in range(len(data)-20):
|
| 64 |
+
if data[i:i+Len_pre]=='"achieved-epic-goals__tokens">':
|
| 65 |
+
ok=True
|
| 66 |
+
ptr=i+Len_pre
|
| 67 |
+
s=''
|
| 68 |
+
while data[ptr]!='代':
|
| 69 |
+
if data[ptr]!=',':
|
| 70 |
+
s+=data[ptr]
|
| 71 |
+
ptr+=1
|
| 72 |
+
tot+=(int(s))
|
| 73 |
+
|
| 74 |
+
f.close()
|
| 75 |
+
#earned_list.append(tot)
|
| 76 |
+
out_f.write(str(tot).encode())
|
| 77 |
+
out_f.write(' '.encode())
|
| 78 |
+
|
| 79 |
+
out_f=open('earned_result.txt','wb')
|
| 80 |
+
for i in range(0,len(usr_name_list)):
|
| 81 |
+
get_profile(usr_name_list[i])
|
| 82 |
+
#cal_earned(usr_name_list[i])
|
| 83 |
+
if i%10==0:
|
| 84 |
+
print(i)
|
| 85 |
+
if i%20==0:
|
| 86 |
+
driver.quit()
|
| 87 |
+
driver=Edge(options=edge_options)
|
| 88 |
+
|
| 89 |
+
out_f.close()
|