python类urlopen()的实例源码

mklabels.py 文件源码 项目:my-first-blog 作者: AnkurBegining 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def generate(url):
    parts = ['''\
"""

    webencodings.labels
    ~~~~~~~~~~~~~~~~~~~

    Map encoding labels to their name.

    :copyright: Copyright 2012 by Simon Sapin
    :license: BSD, see LICENSE for details.

"""

# XXX Do not edit!
# This file is automatically generated by mklabels.py

LABELS = {
''']
    labels = [
        (repr(assert_lower(label)).lstrip('u'),
         repr(encoding['name']).lstrip('u'))
        for category in json.loads(urlopen(url).read().decode('ascii'))
        for encoding in category['encodings']
        for label in encoding['labels']]
    max_len = max(len(label) for label, name in labels)
    parts.extend(
        '    %s:%s %s,\n' % (label, ' ' * (max_len - len(label)), name)
        for label, name in labels)
    parts.append('}')
    return ''.join(parts)
WLE_stats_generation.py 文件源码 项目:WikiLoves 作者: wmes 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def get_global_usage (api_url, query_string_dict, title_list) :
    usage_dict_ = dict()
    usage_dict_["image"] = dict()
    usage_dict_["article"] = dict()
    raw_api_query_string = unicode(u'|'.join(title_list)).encode('utf-8')
    #print raw_api_query_string
    API_QUERY_STRING["titles"] = raw_api_query_string
    f = urlopen(API_BASE_URL, urlencode(API_QUERY_STRING))
    response = f.read()
    response_dict = json.loads(response)
    for key, value in response_dict["query"]["pages"].iteritems():
        if len(value[u'globalusage']) > 0:
            #print value
            found_dict = dict()
            for item in value[u'globalusage']:
                if (item[u'ns'] == u'0') or (item[u'ns'] == u'104'):
                    if item[u'wiki'] in usage_dict_["article"]:
                        usage_dict_["article"][item[u'wiki']] += 1
                    else:
                        usage_dict_["article"][item[u'wiki']] = 1
                    found_dict[item[u'wiki']] = True
            for key, value in found_dict.iteritems():
                if key in usage_dict_["image"]:
                    usage_dict_["image"][key] += 1
                else:
                    usage_dict_["image"][key] = 1
    #print usage_dict_
    return usage_dict_
__init__.py 文件源码 项目:core-framework 作者: RedhawkSDR 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def GetHTTPFileContents( url ):
    fileContents = None
    try:
       filehandle = urllib.urlopen( url )
       return filehandle.read()
    except:
        logging.warning("connection cannot be made to" + url)
        return
saxutils.py 文件源码 项目:kinect-2-libras 作者: inessadl 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def prepare_input_source(source, base = ""):
    """This function takes an InputSource and an optional base URL and
    returns a fully resolved InputSource object ready for reading."""

    if type(source) in _StringTypes:
        source = xmlreader.InputSource(source)
    elif hasattr(source, "read"):
        f = source
        source = xmlreader.InputSource()
        source.setByteStream(f)
        if hasattr(f, "name"):
            source.setSystemId(f.name)

    if source.getByteStream() is None:
        sysid = source.getSystemId()
        basehead = os.path.dirname(os.path.normpath(base))
        sysidfilename = os.path.join(basehead, sysid)
        if os.path.isfile(sysidfilename):
            source.setSystemId(sysidfilename)
            f = open(sysidfilename, "rb")
        else:
            source.setSystemId(urlparse.urljoin(base, sysid))
            f = urllib.urlopen(source.getSystemId())

        source.setByteStream(f)

    return source
travis_pypi_setup.py 文件源码 项目:tokenize-uk 作者: lang-uk 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def fetch_public_key(repo):
    """Download RSA public key Travis will use for this repo.

    Travis API docs: http://docs.travis-ci.com/api/#repository-keys
    """
    keyurl = 'https://api.travis-ci.org/repos/{0}/key'.format(repo)
    data = json.loads(urlopen(keyurl).read().decode())
    if 'key' not in data:
        errmsg = "Could not find public key for repo: {}.\n".format(repo)
        errmsg += "Have you already added your GitHub repo to Travis?"
        raise ValueError(errmsg)
    return data['key']
lfisuite.py 文件源码 项目:LFISuite 作者: D35m0nd142 项目源码 文件源码 阅读 46 收藏 0 点赞 0 评论 0
def download(file_url,local_filename):
    web_file = urllib.urlopen(file_url)
    local_file = open(local_filename, 'w')
    local_file.write(web_file.read())
    web_file.close()
    local_file.close()
pipper.py 文件源码 项目:LFISuite 作者: D35m0nd142 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def download(file_url,local_filename):
    web_file = urllib.urlopen(file_url)
    local_file = open(local_filename, 'w')
    local_file.write(web_file.read())
    web_file.close()
    local_file.close()
updater.py 文件源码 项目:Dr0p1t-Framework 作者: Exploit-install 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def check():
    response = urlopen('https://raw.githubusercontent.com/D4Vinci/Dr0p1t-Framework/master/core/version.txt')
    version = response.read().decode('utf-8').strip()
    f = open( os.path.join("core","version.txt"), 'r')
    file_data = f.read().strip()
    if version != file_data:
        colored_print('\n[*] New Version available ! Visit: https://github.com/D4Vinci/Dr0p1t-Framework\n',"y")
    else:
        colored_print('[*] Your version is up-to-date ;)',"b")
travis_pypi_setup.py 文件源码 项目:libcloud.api 作者: tonybaloney 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def fetch_public_key(repo):
    """Download RSA public key Travis will use for this repo.

    Travis API docs: http://docs.travis-ci.com/api/#repository-keys
    """
    keyurl = 'https://api.travis-ci.org/repos/{0}/key'.format(repo)
    data = json.loads(urlopen(keyurl).read().decode())
    if 'key' not in data:
        errmsg = "Could not find public key for repo: {}.\n".format(repo)
        errmsg += "Have you already added your GitHub repo to Travis?"
        raise ValueError(errmsg)
    return data['key']
wee_discord.py 文件源码 项目:wee-discord 作者: BlitzKraft 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def command_nick(current_buffer, args):
    pass
#    urllib.urlopen("https://%s/account/settings" % (domain))
#    browser.select_form(nr=0)
#    browser.form['username'] = args
#    reply = browser.submit()
travis_pypi_setup.py 文件源码 项目:MDRun 作者: jeiros 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def fetch_public_key(repo):
    """Download RSA public key Travis will use for this repo.

    Travis API docs: http://docs.travis-ci.com/api/#repository-keys
    """
    keyurl = 'https://api.travis-ci.org/repos/{0}/key'.format(repo)
    data = json.loads(urlopen(keyurl).read().decode())
    if 'key' not in data:
        errmsg = "Could not find public key for repo: {}.\n".format(repo)
        errmsg += "Have you already added your GitHub repo to Travis?"
        raise ValueError(errmsg)
    return data['key']
ICML2015.py 文件源码 项目:PaperCrawler 作者: JustJokerX 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_html(url):
    """Get the html """
    page = urllib.urlopen(url)
    html = page.read()
    return html
ICML2016.py 文件源码 项目:PaperCrawler 作者: JustJokerX 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_html(url):
    """Get the html """
    page = urllib.urlopen(url)
    html = page.read()
    return html
NIPS2012.py 文件源码 项目:PaperCrawler 作者: JustJokerX 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def get_html(url):
    """Get the html """
    page = urllib.urlopen(url)
    html = page.read()
    return html
NIPS2016.py 文件源码 项目:PaperCrawler 作者: JustJokerX 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def get_html(url):
    """Get the html """
    page = urllib.urlopen(url)
    html = page.read()
    return html
NIPS2013.py 文件源码 项目:PaperCrawler 作者: JustJokerX 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_html(url):
    """Get the html """
    page = urllib.urlopen(url)
    html = page.read()
    return html
NIPS2014.py 文件源码 项目:PaperCrawler 作者: JustJokerX 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_html(url):
    """Get the html """
    page = urllib.urlopen(url)
    html = page.read()
    return html
CVPR2014.py 文件源码 项目:PaperCrawler 作者: JustJokerX 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_html(url):
    """Get the html """
    page = urllib.urlopen(url)
    html = page.read()
    return html
CVPR2016.py 文件源码 项目:PaperCrawler 作者: JustJokerX 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_html(url):
    """Get the html """
    page = urllib.urlopen(url)
    html = page.read()
    return html
CVPR2015.py 文件源码 项目:PaperCrawler 作者: JustJokerX 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def get_html(url):
    """Get the html """
    page = urllib.urlopen(url)
    html = page.read()
    return html


问题


面经


文章

微信
公众号

扫码关注公众号