コード例 #1
0
def parse_next(id, author_uuid, name, author_url, author_id, begin_years,
               end_years, path, last_page, last_index):
    url = 'http://med.wanfangdata.com.cn/Author/Statistics?id={}'.format(
        author_id)
    html = start(url)
    try:
        if len(html.xpath('//li[@class="hidden-sm"]/span/text()')) != 0:
            total_page = html.xpath(
                '//li[@class="hidden-sm"]/span/text()')[0].strip('共页')
            for page in range(1, int(total_page) + 1):
                if page < last_page:
                    continue
                url = 'http://med.wanfangdata.com.cn/Author/StatisticsPaperList?P={}&Id={}&QueryCode=000&BeginYear={}&EndYear={}&Keywords='.format(
                    str(page), author_id, begin_years, end_years)
                html = start(url)
                parse_literature_info(id, author_uuid, name, author_url,
                                      author_id, url, html, page, path,
                                      last_index)
                last_index = 0
        else:
            page = 1
            parse_literature_info(id, author_uuid, name, author_url, author_id,
                                  url, html, page, path, last_index)
            last_index = 0
    except Exception as x:
        err = traceback.format_exc()
        print(err)
        pass
コード例 #2
0
def parse_analysis_url(author_id, html):
    try:
        begin_year = html.xpath(
            '//select[@id="beginYear"]/option[1]/text()')[0]
        end_year = html.xpath(
            '//select[@id="beginYear"]/option[last()]/text()')[0]
        query_code_ls = [
            '100', '101', '110', '111', '000', '001', '010', '011'
        ]
        ls = []
        for query_code in query_code_ls:
            limit_ls = deal_query_code(query_code)
            url = 'http://med.wanfangdata.com.cn/Author/Statistics?Id={}&QueryCode={}&BeginYear={}&EndYear={}'.format(
                author_id, query_code, begin_year, end_year)
            html = start(url)
            k_ls = parse_analysis(author_id, limit_ls, html, begin_year,
                                  end_year, query_code)
            dic = {}
            dic['source'] = limit_ls[0]
            dic['author_limit'] = limit_ls[1]
            dic['periodical_limit'] = limit_ls[2]
            dic['year_limit'] = begin_year + '-' + end_year
            dic['keywords'] = k_ls
            ls.append(dic)
        pub_statistics = json.dumps(ls, ensure_ascii=False)
        return [pub_statistics, begin_year, end_year]

    except Exception as x:
        err = traceback.format_exc()
        print(err)
        pass
コード例 #3
0
def get_url_other(url):
    try:
        html = start(url)
        pub_author_all = parse_all_pub_num(html)
        pub_author_first = parse_first_pub_num(html)
        click_author = parse_click_num(html)
    except Exception as x:
        err = traceback.format_exc()
        print(err)
        pass
コード例 #4
0
def get_index_same_author(begin_id, end_id):
    try:
        sql = 'select id,author_id,name from t_cl_author_wanfang_index where obj_type!=6'
        list_ret = DbOperBase.common_select(sql, None, DB_CONFIG_SPIDER, True)
        for item in list_ret:
            id = item['id']
            author_id = item['author_id']
            name = item['name']
            url = 'http://med.wanfangdata.com.cn/Author/Search?AuthorName={}&Version=Professional&ExceptAuthorId={}'.format(
                name, author_id)
            html = start(url)
            get_next_url()
    except Exception as x:
        err = traceback.format_exc()
        print(err)
        pass
コード例 #5
0
def tntfollow(number):
    mc = tools.start(0)
    spawn = mc.spawnEntity
    pId = mc.getPlayerEntityId(map(mc.entity.getName, mc.getPlayerEntityIds()))
    start = mc.entity.getTilePos(pId)
    if number == 0:
        while True:
            spawn(pos.up(7), entity.PRIMED_TNT.id)
            pos = mc.entity.getTilePos(pId)
            time.sleep(1)
    else:
        i = 0
        while i < number:
            spawn(pos.up(7), entity.PRIMED_TNT.id)
            pos = mc.entity.getTilePos(pId)
            time.sleep(1)
            i += 1
コード例 #6
0
def get_url(author_id, url):
    try:
        html = start(url)
        page_status = is_page_false(html)
        if page_status:
            source_text = lxml_to_string(html)
            periodical = parse_pub_perio(html)
            fund = parse_fund_relation(html)
            relative_keywords = parse_relative_keywords(html)
            s_ls = parse_analysis_url(author_id, html)
            return [
                periodical, fund, relative_keywords, s_ls[0], s_ls[1], s_ls[2],
                source_text
            ]
        else:
            return [None, None, None, None, None, None, None]
    except Exception as x:
        err = traceback.format_exc()
        print(err)
        pass
コード例 #7
0
def get_url(id, url, author_id, obj_type):
    try:
        html = start(url)
        page_statuse = is_page_false(html)
        if page_statuse:
            source_text = lxml_to_string(html)
            author_org_ls = parse_author_info(html)
            cooperation_author = parse_author_cooperation(
                id, url, author_id, html, obj_type)
            cooperation_relation_org = parse_org_cooperation(html)
            cooperation_relation_author = parse_author_cooperation_relation(
                author_id)
            return [
                author_org_ls[0], author_org_ls[1], cooperation_relation_org,
                cooperation_relation_author, cooperation_author, source_text
            ]
        else:
            return ['', '', None, None, None, None]
    except Exception as x:
        err = traceback.format_exc()
        print(err)
        pass
コード例 #8
0
def get_url(id, author_id, url, obj_type):
    try:
        # SameName_author=None
        html = start(url)
        page_status = is_page_false(html)
        if page_status:
            source_text = lxml_to_string(html)
            pub_author_all = parse_all_pub_num(html)
            pub_author_first = parse_first_pub_num(html)
            click_author = parse_click_num(html)
            SameName_author = get_next_url(id, author_id, url, html, obj_type)
            return [
                SameName_author, pub_author_all, pub_author_first,
                click_author, source_text
            ]
        else:
            return [None, None, None, None, None]

    except Exception as x:
        err = traceback.format_exc()
        print(err)
        pass
コード例 #9
0
def get_next_url(id, author_id, url, html, obj_type):
    try:
        page_num = 1
        ls = []
        while True:
            print(page_num)
            # parse_same_name_author(html)
            SameName_author_part = parse_same_name_author(
                id, author_id, url, html, obj_type)
            ls.append(SameName_author_part)
            SameName_author = json.dumps(ls, ensure_ascii=False)
            if SameName_author == '[null]':
                SameName_author = None
            if len(html.xpath('//li[@class="next"]/a')) != 0:
                next_url = domain + html.xpath(
                    '//li[@class="next"]/a/@href')[0]
                html = start(next_url)
                page_num += 1
            else:
                return SameName_author
    except Exception as x:
        err = traceback.format_exc()
        print(err)
        pass
コード例 #10
0
import sys
sys.path.append("..")

import mcpi.minecraft as mmc
import mcpi.block as block
import tools
from random import choice

mc = tools.start(0)


def testPlaceNoteBlock():
    mc.postToChat(
        "Please input (in-game) the name of the player beside whom the note block system is placed:"
    )
    # name = str(mc.events.pollChatPosts())
    # name = input()

    while True:
        posts = mc.events.pollChatPosts()
        if len(posts) > 0:
            try:
                name = posts[0].message
                id = mc.getPlayerEntityId(name)
            except BaseException:
                mc.postToChat("Wrong name, please input again:")
                continue
            else:
                break

    loc = mc.entity.getPos(id)
コード例 #11
0
import madz

try:
    import zmq
except:
    print("Missing dependency ZMQ")
    exit()
try:
    import PyQt4
    import PyQt4.Qsci
except:
    print("Missing dependency PyQt4 (Full Install)")
    exit()

import os, sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__ ), 'examples')))

import tools

start_target = None
if len(sys.argv) > 1:
    start_target = sys.argv[1]

tools.start(start_target)
コード例 #12
0
ファイル: test.py プロジェクト: ArkciaDragone/Raspy
class Runner():
    def __init__(self, conn):
        print("Runners on their way!")
        self.conn = conn
        sleep(2)
        conn.send("Got it!")
        self.z()

    def z(self):
        print("zing...")
        sleep(2)
        print("zed w")


if __name__ == '__main__':
    mc = start(0)
    while True:
        l = mc.events.pollDeaths()
        if l:
            print(l)
        l = mc.events.pollLogins()
        if l:
            print(l)
        l = mc.events.pollQuits()
        if l:
            print(l)
        l = mc.events.pollRespawns()
        if l:
            print(l)
        sleep(0.2)