当前位置: 首页>>代码示例>>Python>>正文


Python Net.http_POST方法代码示例

本文整理汇总了Python中addon.common.net.Net.http_POST方法的典型用法代码示例。如果您正苦于以下问题:Python Net.http_POST方法的具体用法?Python Net.http_POST怎么用?Python Net.http_POST使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在addon.common.net.Net的用法示例。


在下文中一共展示了Net.http_POST方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: login_and_retry

# 需要导入模块: from addon.common.net import Net [as 别名]
# 或者: from addon.common.net.Net import http_POST [as 别名]
def login_and_retry(redirect):
    _1CH.log('Logging in for url %s' % redirect)
    # needed here because login_and_retry was moved to utils. Probably better to pass in but this works and is quick but dirty.
    USER_AGENT = ("User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64)"
                  "AppleWebKit/537.17 (KHTML, like Gecko)"
                  "Chrome/24.0.1312.56")
    BASE_URL = _1CH.get_setting('domain')
    if (_1CH.get_setting("enableDomain")=='true') and (len(_1CH.get_setting("customDomain")) > 10):
        BASE_URL = _1CH.get_setting("customDomain")

    user = _1CH.get_setting('username')
    passwd = _1CH.get_setting('passwd')
    url = BASE_URL + '/login.php'
    net = Net()
    cookiejar = _1CH.get_profile()
    cookiejar = os.path.join(cookiejar, 'cookies')
    host = re.sub('http://', '', BASE_URL)
    headers = {'Referer': redirect, 'Origin': BASE_URL, 'Host': host, 'User-Agent': USER_AGENT}
    form_data = {'username': user, 'password': passwd, 'remember': 'on', 'login_submit': 'Login'}
    html = net.http_POST(url, headers=headers, form_data=form_data).content
    if '<a href="/logout.php">[ Logout ]</a>' in html:
        net.save_cookies(cookiejar)
        return html
    else:
        _1CH.log('Failed to login')
        print html
开发者ID:GoSexyCA,项目名称:1Channel,代码行数:28,代码来源:utils.py

示例2: resolve_cloudyvideos

# 需要导入模块: from addon.common.net import Net [as 别名]
# 或者: from addon.common.net.Net import http_POST [as 别名]
def resolve_cloudyvideos(name,url,iconimage):
        # print "cloudyvideos"
        url=re.sub('embed-|-.*?(?:\.html)','',url)
        net = Net()
        web_url = url
        headers = {'Referer': web_url}
        html = net.http_GET(web_url, headers=headers).content
        data={}
        time.sleep(3)
        for match in re.finditer(r'type="hidden".*?name="([^"]+)".*?value="([^"]+)', html):
            data[match.group(1)] = match.group(2)
            data.update ({'method_free': 'Continue'})
        htmla = net.http_POST(web_url, data).content
        r = re.search('file:\s*\'(.*?)\',+', htmla)
        pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
        pl.clear()
        try:
            listitem = xbmcgui.ListItem(name,thumbnailImage=iconimage)
            url = r.group(1)+'|Referer=http://cloudyvideos&User-Agent=%s' % (USER_AGENT)
            pl.add(url, listitem)
            xbmc.Player().play(pl)
        except Exception, e:
            dialog = xbmcgui.DialogProgress()
            dialog1 = xbmcgui.Dialog()
            dialog1.ok('error','[UPPERCASE][B]                Sorry but the video is deleted!!![/B][/UPPERCASE]')
            print '**** cloudyvideo Error occured: %s' % e
            raise
开发者ID:noba3,项目名称:KoTos,代码行数:29,代码来源:default.py

示例3: __login

# 需要导入模块: from addon.common.net import Net [as 别名]
# 或者: from addon.common.net.Net import http_POST [as 别名]
 def __login(self,redirect):
     url = self.base_url + '/login.php'
     net = Net()
     cookiejar = _1CH.get_profile()
     cookiejar = os.path.join(cookiejar, 'cookies')
     host = re.sub('http://', '', self.base_url)
     headers = {'Referer': redirect, 'Origin': self.base_url, 'Host': host, 'User-Agent': USER_AGENT}
     form_data = {'username': self.username, 'password': self.password, 'remember': 'on', 'login_submit': 'Login'}
     html = net.http_POST(url, headers=headers, form_data=form_data).content
     if '<a href="/logout.php">[ Logout ]</a>' in html:
         net.save_cookies(cookiejar)
         return True
     else:
         return False
开发者ID:crashcoredump,项目名称:1Channel,代码行数:16,代码来源:pw_scraper.py

示例4: request

# 需要导入模块: from addon.common.net import Net [as 别名]
# 或者: from addon.common.net.Net import http_POST [as 别名]
 def request(self, uri, params=None, query=None, headers=None, return_soup=False, return_json=False):
     COOKIE_JAR = vfs.join(COOKIE_PATH, self.service + ".lwp")
     net = Net()
     net.set_cookies(COOKIE_JAR)
     if headers:
         headers["Referer"] = self.referrer
         headers["Accept"] = self.ACCEPT
         headers["User-Agent"] = self.USER_AGENT
     else:
         headers = {"Referer": self.referrer, "Accept": self.ACCEPT, "User-Agent": self.USER_AGENT}
     if query:
         uri = uri % urllib.urlencode(query)
     if params:
         html = net.http_POST(self.base_url + uri, params, headers=headers).content
     else:
         html = net.http_GET(self.base_url + uri, headers=headers).content
     net.save_cookies(COOKIE_JAR)
     if return_soup:
         return BeautifulSoup(html)
     elif return_json:
         return json.loads(html)
     else:
         return html
开发者ID:natko1412,项目名称:script.module.dudehere.routines,代码行数:25,代码来源:__init__.py


注:本文中的addon.common.net.Net.http_POST方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。