#!/usr/bin/python3
# -*- coding: UTF-8 -*-
from urllib import request
from http import cookiejar
import json,time,re,sys,getch
###############cookiejar################
search_name = sys.argv[1]
str_put = request.quote(search_name)
cookie = cookiejar.CookieJar()
cookie_handle = request.HTTPCookieProcessor(cookie)
opener = request.build_opener(cookie_handle)
header={
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
#"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9",
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
"Host": "pansou.com",
"Referer": "http://pansou.com/?q=openstack",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36"
}
url = request.Request("http://pansou.com/",headers=header)
opener.open(url).read()
def evenkey():
key = getch.getch()
if key == '\x1b':
getch.getch()
return getch.getch()
else :
return key
def get_pack():
key = 1
while True:
url = request.Request("http://106.15.195.249:8011/search_new?callback=jQuery1720524545886100632_1558068202862&q="+ str_put + "&p="+str(key)+"&_="+str(int(time.time())),headers=header)
html = opener.open(url).read()
html = html.decode(encoding="utf8")
html=re.findall('{.*}',html)[0]
html = json.loads(html).get("list").get("data")
for i in html:
print(i.get("title"))
print(i.get("link"))
print(i.get("des"))
# print(i.get("time"))
print("--------------------------------------------------------------------")
if evenkey() == 'B':
key = key + 1
else :
if key < 2 :
key = 1
else :
key = key -1
get_pack()