Exemple #1
0
def main(search_keyword):
    url = get_url(search_keyword)
    req = urllib_request_Request(
        url,
        headers={
            'User-Agent':
            'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'
        })
    page_content = urllib_request_urlopen(req).read().decode('utf8')

    return get_youku_result(search_keyword, page_content)
Exemple #2
0
def add_items(opener, folderId, release_name):
    "Add the 12(!) items for a release to the given folder"
    folder_add_url = 'http://subversion.tigris.org/servlets/ProjectDocumentAdd?folderID=%d&action=Add%%20document' % folderId

    if re.match('^\d*\.\d*\.\d*$', release_name):
      status = 'Stable'
    else:
      status = 'Draft'

    md5sums = get_md5sums()

    for ext in ['.zip', '.tar.gz', '.tar.bz2']:
        for deps in ['', '-deps']:
            filename = 'subversion%s-%s%s' % (deps, release_name, ext)
            desc = 'Subversion %s' % release_name
            if deps:
                desc = desc + ' Dependencies'

            params = {
                'name' : filename,
                'status' : status,
                'description' : '%s (MD5: %s)' % (desc, md5sums[filename]),
                'type': 'link',
                'url': 'http://subversion.tigris.org/downloads/%s' % filename,
                'maxDepth': '',
            }

            # Add file
            request = urllib_request_Request(folder_add_url,
                                             urllib_parse_urlencode(params))
            opener.open(request)

            # Add signature
            filename = filename + '.asc'
            params['name'] = filename
            params['description'] = 'PGP signatures for %s' % desc
            params['url'] = 'http://subversion.tigris.org/downloads/%s' % \
                                                                      filename
            request = urllib_request_Request(folder_add_url,
                                             urllib_parse_urlencode(params))
            opener.open(request)
Exemple #3
0
def add_items(opener, folderId, release_name):
    "Add the 12(!) items for a release to the given folder"
    folder_add_url = 'http://subversion.tigris.org/servlets/ProjectDocumentAdd?folderID=%d&action=Add%%20document' % folderId

    if re.match('^\d*\.\d*\.\d*$', release_name):
        status = 'Stable'
    else:
        status = 'Draft'

    md5sums = get_md5sums()

    for ext in ['.zip', '.tar.gz', '.tar.bz2']:
        for deps in ['', '-deps']:
            filename = 'subversion%s-%s%s' % (deps, release_name, ext)
            desc = 'Subversion %s' % release_name
            if deps:
                desc = desc + ' Dependencies'

            params = {
                'name': filename,
                'status': status,
                'description': '%s (MD5: %s)' % (desc, md5sums[filename]),
                'type': 'link',
                'url': 'http://subversion.tigris.org/downloads/%s' % filename,
                'maxDepth': '',
            }

            # Add file
            request = urllib_request_Request(folder_add_url,
                                             urllib_parse_urlencode(params))
            opener.open(request)

            # Add signature
            filename = filename + '.asc'
            params['name'] = filename
            params['description'] = 'PGP signatures for %s' % desc
            params['url'] = 'http://subversion.tigris.org/downloads/%s' % \
                                                                      filename
            request = urllib_request_Request(folder_add_url,
                                             urllib_parse_urlencode(params))
            opener.open(request)
Exemple #4
0
def main(search_keyword):
    url = get_url(search_keyword)
    req = urllib_request_Request(
        url,
        headers={
            'User-Agent':
            'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'
        })
    page_content = urllib_request_urlopen(req).read().decode('utf8')

    baidu_search_result = dict()
    #baidu_search_result.update(get_baidu_result_2(search_keyword, page_content))
    baidu_search_result.update(get_baidu_result_1(search_keyword,
                                                  page_content))

    return {e[1]: e[0] for e in baidu_search_result.items()}
Exemple #5
0
def login(username, password, folderId):
    '''Login to tigris.org, using the provided username and password.
       Return the OpenDirector object for future use.'''
    cj = cookielib.CookieJar()
    opener = urllib_request_build_opener(urllib_request_HTTPCookieProcessor(cj))

    folderURL = 'http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=%d' % folderId,
    params = {
        'detour' : folderURL,
        'loginID' : username,
        'password' : password,
      }
    request = urllib_request_Request('http://www.tigris.org/servlets/TLogin',
                                     urllib_parse_urlencode(params))
    # We open the above request, grabbing the appropriate credentials for
    # future interactions.
    opener.open(request)

    return opener
Exemple #6
0
def login(username, password, folderId):
    '''Login to tigris.org, using the provided username and password.
       Return the OpenDirector object for future use.'''
    cj = cookielib.CookieJar()
    opener = urllib_request_build_opener(
        urllib_request_HTTPCookieProcessor(cj))

    folderURL = 'http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=%d' % folderId,
    params = {
        'detour': folderURL,
        'loginID': username,
        'password': password,
    }
    request = urllib_request_Request('http://www.tigris.org/servlets/TLogin',
                                     urllib_parse_urlencode(params))
    # We open the above request, grabbing the appropriate credentials for
    # future interactions.
    opener.open(request)

    return opener