Skip to content

Commit 71df20e

Browse files
author
danbai225
committed
.
1 parent 1f6f919 commit 71df20e

File tree

3 files changed

+31
-46
lines changed

3 files changed

+31
-46
lines changed

py/gxpa.py

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
# ping MySQL服务端,检查是否服务可用。# 如:0 = None = never, 1 = default = whenever it is requested, 2 = when a cursor is created, 4 = when a query is executed, 7 = always
2121
host='127.0.0.1',
2222
port=3306,
23-
user='123',
24-
password='123',
23+
user='ys',
24+
password='password',
2525
database='ys',
2626
charset='utf8'
2727
)
@@ -31,31 +31,12 @@ class Ji:
3131
def __init__(self, name, url):
3232
self.name = name
3333
self.url = url
34-
35-
proxys=[]
3634
header = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36'}
37-
#获取代理
38-
def get_proxy():
39-
global proxys
40-
r=requests.get("http://ip.jiangxianli.com/")
41-
if(r.status_code==200):
42-
selector=etree.HTML(r.text)
43-
proxys=proxys+selector.xpath("//button[@class=\"btn btn-sm btn-copy\"]/@data-url")
4435
#获取页面html
4536
def getHtml(url):
46-
global proxys
47-
p=proxys[random.randint(0,len(proxys)-1)]
48-
try:
49-
html = requests.get(url,proxies={'http':p},headers=header,timeout=5)
50-
if html!=None:
51-
return html.text
52-
except Exception:
53-
proxys.remove(p)
54-
if len(proxys)<2:
55-
get_proxy()
56-
return getHtml(url)
37+
html = requests.get(url,headers=header,timeout=5)
38+
return html.text
5739
def main():
58-
get_proxy()
5940
list=[]
6041
for i in range(1,5):
6142
selector=etree.HTML(getHtml("http://www.zuidazy1.net/?m=vod-type-id-{}.html".format(i)))

py/pa.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
host='127.0.0.1',
2424
port=3306,
2525
user='ys',
26-
password='***',
27-
database='**',
26+
password='password',
27+
database='ys',
2828
charset='utf8'
2929
)
3030
class Ji:

py/tagpa.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
setsession=[], # 开始会话前执行的命令列表。如:["set datestyle to ...", "set time zone ..."]
2020
ping=0,
2121
# ping MySQL服务端,检查是否服务可用。# 如:0 = None = never, 1 = default = whenever it is requested, 2 = when a cursor is created, 4 = when a query is executed, 7 = always
22-
host='39.108.110.44',
22+
host='127.0.0.1',
2323
port=3306,
2424
user='ys',
25-
password='***',
25+
password='password',
2626
database='ys',
2727
charset='utf8'
2828
)
@@ -36,28 +36,32 @@ def get_proxy():
3636
selector=etree.HTML(r.text)
3737
proxys=proxys+selector.xpath('//button[@class="layui-btn layui-btn-sm btn-copy"]/@data-url')
3838
#获取页面html
39-
def getHtml(url):
40-
global proxys
41-
p=proxys[random.randint(0,len(proxys)-1)]
42-
try:
43-
pp=p.replace("http://","")
44-
pp=pp.replace("https://","")
45-
html = requests.get(url,proxies={'http':pp},headers=header,timeout=5)
46-
if html!=None:
47-
return html.text
48-
except Exception:
49-
proxys.remove(p)
50-
if len(proxys)<2:
51-
get_proxy()
52-
return getHtml(url)
39+
def getHtml(url,p):
40+
if p:
41+
global proxys
42+
p=proxys[random.randint(0,len(proxys)-1)]
43+
try:
44+
pp=p.replace("http://","")
45+
pp=pp.replace("https://","")
46+
html = requests.get(url,proxies={"http":pp},headers=header,timeout=5)
47+
if html!=None:
48+
return html.text
49+
except Exception:
50+
proxys.remove(p)
51+
if len(proxys)<2:
52+
get_proxy()
53+
return getHtml(url,True)
54+
else :
55+
html = requests.get(url,headers=header,timeout=5)
56+
return html.text
5357
def main():
5458
global proxys
5559
get_proxy()
5660
conn = POOL.connection()
5761
cursor = conn.cursor()
58-
cursor.execute("SELECT id,pm,dy,lx,gkdz,xzdz FROM `ysb` ORDER BY `gxtime` DESC LIMIT 30")
62+
cursor.execute("SELECT id,pm,dy,lx,gkdz,xzdz FROM `ysb` ORDER BY `gxtime` DESC LIMIT 60")
5963
data = cursor.fetchall()
60-
rpool = redis.ConnectionPool(host='39.108.110.44', port=6379,db=0,password='***')
64+
rpool = redis.ConnectionPool(host='127.0.0.1', port=6379,db=0)
6165
pool = ThreadPool(30)
6266
for ys in data:
6367
try:
@@ -80,15 +84,15 @@ def run(ys,r):
8084
else:
8185
tnum=int(tnum)
8286
if tnum<len(jys):
83-
fh=getHtml("http://v.qq.com/x/search/?q="+pm)
87+
fh=getHtml("http://v.qq.com/x/search/?q="+pm,False)
8488
ysid=re.compile("{id: '(.*)'; type: '2';}",re.M).findall(fh)[0]
85-
fh=getHtml("http://s.video.qq.com/get_playsource?plat=2&type=4&range=1&otype=json&id="+ysid)
89+
fh=getHtml("http://s.video.qq.com/get_playsource?plat=2&type=4&range=1&otype=json&id="+ysid,True)
8690
jsonj=json.loads(fh[13:-1])
8791
jlist=jsonj["PlaylistItem"]["videoPlayList"]
8892
taglist=[]
8993
if jsonj["PlaylistItem"]['payType']==2:
9094
for i in range (0,len(jlist)):
91-
tfh=getHtml("http://bullet.video.qq.com/fcgi-bin/target/regist?otype=json&vid="+jlist[i]['id'])
95+
tfh=getHtml("http://bullet.video.qq.com/fcgi-bin/target/regist?otype=json&vid="+jlist[i]['id'],False)
9296
tagid=json.loads(tfh[13:-1])['targetid']
9397
taglist.append(tagid)
9498
taglist.reverse()

0 commit comments

Comments
 (0)