Ejemplo n.º 1
0
 def outReceived(self, data):
     global pid
     print(data)
     if pid == 0:
         #print("received:",data[:4])
         if data[:4] == b"\x00\xd0\x9d\x09":
             pid = int(re.findall(r'[0-9]+', data[4:].decode())[0])
             #print("pid:",pid)
     # it is here.
     up(time.time(), pid, data, {"type": "output"})
Ejemplo n.º 2
0
def main():
    keyword = input("输入关键字:")
    page = input("输入查找页数:")
    url = get_url(keyword)
    results = parse_page(url, page)
    # 写入文件
    # file = open("data.json", 'w+', encoding='utf-8')
    file = 0
    t = int(time.time())
    for result in results:
        up(t, file, keyword, result)
        file += 1
        # waht if we want to use the result?
        print(result)
Ejemplo n.º 3
0
def main():
    keyword = input("输入关键字:")
    # only supports one page.
    # page = input("输入查找页数:")
    # url = get_url(keyword)
    # p=int(page)
    # results=ml([getLinked(keyword) for d in range(p)])
    results = getLinked(keyword)
    # results = parse_page(url, page)
    # # 写入文件
    # file = open("data.json", 'w+', encoding='utf-8')
    # it is not that fast.
    file = -1
    t = int(time.time())
    for result in results:
        up(t, file, keyword, result)
        file -= 1
        # waht if we want to use the result?
        print(result)
Ejemplo n.º 4
0
        break
    except:
        e = traceback.format_exc()
        print(e)
        continue
while True:
    # print(i)
    # what about query?
    p = [x for x in parse_page(get_url(a), b_page)]
    y = [jieba.lcut_for_search(x['title']) for x in p]
    z = [jieba.lcut_for_search(x['abstract']) for x in p]
    # for x in p:
    file = 0
    t = int(time.time())
    for result in p:
        up(t, file, a, result)
        file += 1
        # waht if we want to use the result?
        print(result)
    halt = 0
    while True:
        try:
            r = random.choice(random.choice(y))
            f = random.choice(random.choice(z))
            if len(r) > 10 or len(f) > 10:
                continue
            k = " ".join([r, f])
            if check_duplicate(k, i):
                continue
        except:
            e = traceback.format_exc()
Ejemplo n.º 5
0
from dbM import showX, up
import pypi_get as pg

s = showX("projects", 0)
for x, y in s:
    try:
        p = pg.get(y)
        print("fetching success")
        up(x, p)
    except:
        print("fetching error")
Ejemplo n.º 6
0
 def errReceived(self, data):
     global pid
     print(data)
     up(time.time(), pid, data, {"type": "error"})
Ejemplo n.º 7
0
 # start after the set.
 # somehow.
 # all dead here. not even better than JS.
 p.start()  # not RUN!
 # what the heck?
 # with TIMESTAMP.
 # print("{OF}")
 ik = 10
 #pp.write(b"parrot\n")
 time.sleep(1)
 # not working here.
 while ik > 0:
     inp = onceMore()
     print(inp)
     pp.write(inp)
     up(time.time(), pid, inp, {"type": "input"})
     time.sleep(.500)
     ik -= 1
 pp.write(b"exit\n")
 time.sleep(1)
 # this will provide the debug info.
 pp.write(b"ls\n")
 time.sleep(1)
 # this will not work.
 # p.kill()
 # print(dir(p))
 # quit()
 print("__EOL__")
 # sys.exit()
 exit()
 # it works.
Ejemplo n.º 8
0
 def errReceived(self, data):
     up(time.time(), pid, data, {"type": "error"})
Ejemplo n.º 9
0
 def outReceived(self, data):
     up(time.time(), pid, data, {"type": "output"})