猫史档案馆


ABS寄予清风NotFound

ABS寄予清风NotFound

Lv.1

一个人

获赞:48收藏:17浏览:428作品收藏:14

签名:我正在写作业……

回复帖子评论
上一页1 页 / 共 5下一页

【代码岛3.0新地图情报泄露??】 中回复

当然是4

冰火峡谷

2019-11-17T17:11:27 点赞:0

【话说有人会盲打吗】 中回复

1.5

2019-11-22T15:15:34 点赞:0

【海龟编辑器】意见反馈信箱(长期有效) 中回复

使用pygame库,居然pygame.error,说调用不出来图片

 

2019-11-22T20:35:26 点赞:1

【代码岛3.0内测第8弹-地图编辑!!】限时体验! 中回复

我也要参加

 

2019-12-14T20:33:03 点赞:0

【代码岛3.0内测第8弹-地图编辑!!】限时体验! 中回复

吉吉瞄,我想参加代码岛3.0的创作,我想和大家一起,建设起一个好地图,让大家自在得玩可以吗?谢谢

 

2019-12-14T20:43:40 点赞:0

【0成本建网站】【第一期】注册账号 中回复

为什么360不行?说Your browser did something unexpected. Please contact us if the problem persists.你的浏览器做了一些意想不到的事情。如果问题仍然存在,请与我们联系???

 

2019-12-14T20:57:29 点赞:0

【0成本建网站】【第四期】修改文字——别催别催,今天还没过完呢! 中回复

tangzengxian.github.io

2019-12-18T13:32:44 点赞:0

【代码岛3.0内测第8弹-地图编辑!!】限时体验! 中回复

1. 原因

    我想只做一个好的作品,让大家玩。

2. 链接

    https://box3.codemao.cn/content/2/1989

吉吉喵,我想参加。

2019-12-23T17:33:35 点赞:1

【请回答】3D画板你想看画什么?你说我画 中回复

吉吉喵,手机可以吗?

2019-12-30T20:30:40 点赞:0

【代码岛3.0绝密文档泄露??!!】谁能破译 中回复

这个程序告诉我们:英语要学好,不然代码和注释都看不懂,其实都是英文……

2020-01-06T14:39:06 点赞:0

【0成本建网站】【第四期】修改文字——别催别催,今天还没过完呢! 中回复

有五个人了,大哥

2020-01-16T11:14:26 点赞:0

【歪python】??? 中回复

不行吧

2020-01-17T11:56:33 点赞:0

【Python作品分享】高级爬虫【作品秀】 中回复

import re
import urlparse
import urllib2
import time
from datetime import datetime
import robotparser
import Queue
from scrape_callback3 import ScrapeCallback


def link_crawler(seed_url, link_regex=None, delay=5, max_depth=-1, max_urls=-1, headers=None, user_agent='wswp',
                 proxy=None, num_retries=1, scrape_callback=None):
    """Crawl from the given seed URL following links matched by link_regex
    """
    # the queue of URL's that still need to be crawled
    crawl_queue = [seed_url]
    # the URL's that have been seen and at what depth
    seen = {seed_url: 0}
    # track how many URL's have been downloaded
    num_urls = 0
    rp = get_robots(seed_url)
    throttle = Throttle(delay)
    headers = headers or {}
    if user_agent:
        headers['User-agent'] = user_agent

    while crawl_queue:
        url = crawl_queue.pop()
        depth = seen[url]
        # check url passes robots.txt restrictions
        if rp.can_fetch(user_agent, url):
            throttle.wait(url)
            h喵l = download(url, headers, proxy=proxy, num_retries=num_retries)
            links = []
            if scrape_callback:
                links.extend(scrape_callback(url, h喵l) or [])

            if depth != max_depth:
                # can still crawl further
                if link_regex:
                    # filter for links matching our regular expression
                    links.extend(link for link in get_links(h喵l) if re.match(link_regex, link))

                for link in links:
                    link = normalize(seed_url, link)
                    # check whether already crawled this link
                    if link not in seen:
                        seen[link] = depth + 1
                        # check link is within same domain
                        if same_domain(seed_url, link):
                            # success! add this new link to queue
                            crawl_queue.append(link)

            # check whether have reached downloaded maximum
            num_urls += 1
            if num_urls == max_urls:
                break
        else:
            print 'Blocked by robots.txt:', url


class Throttle:
    """Throttle downloading by sleeping between requests to same domain
    """

    def __init__(self, delay):
        # amount of delay between downloads for each domain
        self.delay = delay
        # timestamp of when a domain was last accessed
        self.domains = {}

    def wait(self, url):
        """Delay if have accessed this domain recently
        """
        domain = urlparse.urlsplit(url).netloc
        last_accessed = self.domains.get(domain)
        if self.delay > 0 and last_accessed is not None:
            sleep_secs = self.delay - (datetime.now() - last_accessed).seconds
            if sleep_secs > 0:
                time.sleep(sleep_secs)
        self.domains[domain] = datetime.now()


def download(url, headers, proxy, num_retries, data=None):
    print 'Downloading:', url
    request = urllib2.Request(url, data, headers)
    opener = urllib2.build_opener()
    if proxy:
        proxy_params = {urlparse.urlparse(url).scheme: proxy}
        opener.add_handler(urllib2.ProxyHandler(proxy_params))
    try:
        response = opener.open(request)
        h喵l = response.read()
        code = response.code
    except urllib2.URLError as e:
        print 'Download error:', e.reason
        h喵l = ''
        if hasattr(e, 'code'):
            code = e.code
            if num_retries > 0 and 500 <= code < 600:
                # retry 5XX HTTP errors
                h喵l = download(url, headers, proxy, num_retries - 1, data)
        else:
            code = None
    return h喵l


def normalize(seed_url, link):
    """Normalize this URL by removing hash and adding domain
    """
    link, _ = urlparse.urldefrag(link)  # remove hash to avoid duplicates
    return urlparse.ur喵oin(seed_url, link)


def same_domain(url1, url2):
    """Return True if both URL's belong to same domain
    """
    return urlparse.urlparse(url1).netloc == urlparse.urlparse(url2).netloc


def get_robots(url):
    """Initialize robots parser for this domain
    """
    rp = robotparser.RobotFileParser()
    rp.set_url(urlparse.ur喵oin(url, '/robots.txt'))
    rp.read()
    return rp


def get_links(h喵l):
    """Return a list of links from h喵l
    """
    # a regular expression to extract all links from the webpage
    webpage_regex = re.compile(']+href=["\'](.*?)["\']', re.IGNORECASE)
    # list of all links from the webpage
    return webpage_regex.findall(h喵l)


if __name__ == '__main__':
    # link_crawler('http://example.webscraping.com', '/(index|view)', delay=0, num_retries=1, user_agent='BadCrawler')
    # link_crawler('http://example.webscraping.com', '/(index|view)', delay=0, num_retries=1, max_depth=1,
    #              user_agent='GoodCrawler')
    link_crawler('http://fund.eas喵oney.com',r'/fund.h喵l#os_0;isall_0;ft_;pt_1',max_depth=-1,scrape_callback=ScrapeCallback

 

2020-01-17T11:57:52 点赞:0

【统计】各位都玩了什么游戏? 中回复

ACGHI

2020-01-17T15:15:10 点赞:0

【代码岛3.0内测第9弹 - 编程!!】首批编程大师招募! 中回复

吉吉喵,为什么没有坐标轴?就是我在创作的时候,想搞一个传送门,但是我的xyz坐标都没搞清楚。

2020-01-17T15:22:01 点赞:0

【你问我答】你们有关C++,都知道多少? 中回复

2020-01-24T15:30:31 点赞:0

【0成本建网站】【第四期】修改文字——别催别催,今天还没过完呢! 中回复

有五个人了,大哥

2020-01-28T15:38:01 点赞:0

一起创作地图 中回复

https://shequ.codemao.cn/community/231153

2020-02-01T12:53:59 点赞:0

谢谢您a. 中回复

有人破坏了我地图

2020-02-01T12:54:51 点赞:0

为什么会被屏蔽?【那些奇怪的“喵”】 中回复

微信

 

2020-02-03T11:21:30 点赞:0

【代码岛3.0编辑器更新!】添加999个实体,居然很流畅? 中回复

嘤嘤嘤~吉吉喵,我用ipad有bug!

我想飞行,结果居然……飞的不知道哪里去了!而且跳跃按键也不见了!!!

2020-02-15T08:02:22 点赞:1

@吉吉喵! 中回复

emm……

非要用DEVC++

vscode不香吗?

😓

2020-02-17T17:55:19 点赞:0

【代码岛3.0科普贴】怎么将地面全部变成水? 中回复

good

 

2020-02-20T14:55:18 点赞:0

【代码岛3.0科普贴】怎么将地面全部变成水? 中回复

for (let i = 0; i < 128; i++) {
    for (let j = 6; j < 9; j++) {
        for (let k = 0; k < 128; k++) {
            voxels.setVoxel(i, j, k, 'water')
        }
    }
}

吉吉喵,isThis?

2020-02-20T17:38:43 点赞:1

【代码岛3.0几个小技巧】代码岛3.0奇妙城市跑酷技巧 中回复

31251.323正在尝试记录。

2020-02-23T02:43:53 点赞:0

【代码岛3.0内测第9弹 - 编程!!】首批编程大师招募! 中回复

吉吉喵,那个介绍打年兽迎新春的地图的帖子呢?

2020-02-23T03:00:53 点赞:0

【大新闻】吉吉喵首次直播ing - 评测代码岛3.0双周创作赛拯救作品!! 中回复

板凳

2020-02-23T10:18:08 点赞:0

【大新闻】吉吉喵首次直播ing - 评测代码岛3.0双周创作赛拯救作品!! 中回复

?!没动静。

2020-02-23T10:19:12 点赞:0

【大新闻】吉吉喵首次直播ing - 评测代码岛3.0双周创作赛拯救作品!! 中回复

在主页干什么?吉吉喵去哪里了?

2020-02-23T10:19:35 点赞:0

【大新闻】吉吉喵首次直播ing - 评测代码岛3.0双周创作赛拯救作品!! 中回复

吉吉喵快点评测呀。

2020-02-23T10:20:02 点赞:0