class Getter(metaclass=GetMetaclass): def __init__(self): self.fetcher = Fetcher() def get_info(self, callback, url): crawl_func = eval('self.{0}'.format(callback)) return crawl_func(url) def crawl_weixin(self, url): result = {} res = self.fetcher.get(url) soup = BeautifulSoup(res.content, 'html.parser', from_encoding='utf8') item_imgs = soup.select('#page-content img[data-src!=""]') imgs = [item_img['data-src'] for item_img in item_imgs] title = soup.select('h2#activity-name')[0].text.strip() result['url'] = url result['imgs'] = imgs result['title'] = title result['content'] = res.content return result def crawl_youdao(self, url): report = {} res = self.fetcher.get(url) soup = BeautifulSoup(res.content, 'html.parser', from_encoding='utf8') item_imgs = soup.select('.post-bd img[src!=""]') imgs = [item_img['src'] for item_img in item_imgs] report['url'] = url report['imgs'] = imgs report['content'] = res.content return report
print(f' Source file: {src}') print(f' Source length: {len(insts)}\n') # src instruction simulation while True: ''' if pc > 58 and cycle % 100 == 0: input(f"cycle={cycle}, full={issuequeue.full()}, block={branch_block}, pc = {pc}") ''' #debug(f'CYCLE:{cycle}, PC:{pc}') # if issue queue is not full, i.e. can fetch and decode if not issuequeue.full() and not branch_block and pc < len(insts): # fetch fetcher.send() pc, branch_block = fetcher.get(pc, insts) ''' if branch_block: print(f"BRANCH BLOCKED! at {pc}") ''' else: fetcher.send() # decode decoder.send() decoder.decode() decoder.recv(fetcher.to_decoder()) # issue queue issuequeue.enqueue(decoder.to_issuequeue())