File size: 2,883 Bytes
5a29a9d
97e3e43
2da44f3
97e3e43
 
fbb5e1a
97e3e43
cf42ca0
97e3e43
 
 
 
5a29a9d
 
97e3e43
 
 
 
 
 
 
 
 
 
cf42ca0
 
 
 
5a29a9d
6512c0f
 
5a29a9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
'''import gradio as gr
import urllib.request
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'}
def getHtml(url):
    print(url)
    html = urllib.request.urlopen(url,headers).read()
    return html

def saveHtml(file_name, file_content):
    with open(file_name.replace('/', '_') + ".html", "wb") as f:
        f.write(file_content)
usr_name_list=['NikaLegran']
with open('user.txt','rb') as f1:
    usr_name_list=bytes.decode(f1.read()).split(' ')
#print(usr_name_list[:10])
for i in range(len(usr_name_list)):
    #url = "http://www.view.sdu.edu.cn/info/1003/75240.htm"
    usr_name=usr_name_list[i]
    url = 'https://zh.stripchat.com/'+usr_name+'/profile'
    html = getHtml(url)

    saveHtml(''+usr_name, html)
    if i%20==0:
        print(i)
def greet(name):
    return "Hello " + name + "!!"

iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()'''
import os
os.system("pip3 install selenium")
from selenium import webdriver 
import time
from msedge.selenium_tools import EdgeOptions
from msedge.selenium_tools import Edge
edge_options = EdgeOptions()
edge_options.use_chromium = True
# 设置无界面模式,也可以添加其它设置
edge_options.add_argument('headless')
driver=Edge(options=edge_options)
usr_name_list=['NikaLegran']
with open('user.txt','rb') as f1:
    usr_name_list=bytes.decode(f1.read()).split(' ')
print(usr_name_list[:10])
earned_list=[]
def get_profile(usr_name,rt='F:/model_profile/'):
    get_html = rt+usr_name+".html" 
    #打开文件,准备写入
    f = open(get_html,'wb')
    url = 'https://zh.stripchat.com/'+usr_name+'/profile' # 这里填你要保存的网页的网址
    driver.get(url)
    time.sleep(0.9) # 保证浏览器响应成功后再进行下一步操作
    #写入文件
    f.write(driver.page_source.encode("utf-8", "ignore")) 
    f.close()  

def cal_earned(usr_name,rt='F:/model_profile/'):
    
#get_profile(usr_name,'./')   
    f=open(rt+usr_name+'.html','rb')
    data=bytes.decode(f.read())
    Len_pre=len('"achieved-epic-goals__tokens">')
    tot=0
    ok=False
    for i in range(len(data)-20):
        if data[i:i+Len_pre]=='"achieved-epic-goals__tokens">':
            ok=True
            ptr=i+Len_pre
            s=''
            while data[ptr]!='代':
                if data[ptr]!=',':
                    s+=data[ptr]
                ptr+=1
            tot+=(int(s))
            
    f.close()     
    #earned_list.append(tot)
    out_f.write(str(tot).encode())
    out_f.write(' '.encode())
    
out_f=open('earned_result.txt','wb')
for i in range(0,len(usr_name_list)):
    get_profile(usr_name_list[i])
    #cal_earned(usr_name_list[i])
    if i%10==0:
        print(i)
    if i%20==0:
        driver.quit()
        driver=Edge(options=edge_options)
               
out_f.close()