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


Python twitter.com方法代码示例

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


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

示例1: test_quote_tweet_mention_mangle_1

# 需要导入模块: import twitter [as 别名]
# 或者: from twitter import com [as 别名]
def test_quote_tweet_mention_mangle_1(self):

        status = self.thaw_tweet('quote_tweet_mention_mangle_1')

        tweet = Tweet(self.settings, status, self.api)

        expected_content = """Say no to spec work.
https://euronews.com/2019/04/15/fire-underway-at-notre-dame-cathedral-in-paris-firefighters-say
Source: https://twitter.com/EPhilippePM/status/1118472220509126661
cc @nospec
---
RT @EPhilippePM
Faut-il reconstruire une flèche ? À l’identique ? Adaptée aux techniques et aux enjeux de notre époque ? Un concours international d’architecture portant sur la reconstruction de la flèche de la cathédrale sera organisé. #Not…
https://twitter.com/EPhilippePM/status/1118472220509126661"""

        self.assertEqual(expected_content, tweet.clean_content) 
开发者ID:foozmeat,项目名称:moa,代码行数:18,代码来源:test_tweets.py

示例2: testGettersAndSetters

# 需要导入模块: import twitter [as 别名]
# 或者: from twitter import com [as 别名]
def testGettersAndSetters(self):
    '''Test all of the twitter.User getters and setters'''
    user = twitter.User()
    user.SetId(673483)
    self.assertEqual(673483, user.GetId())
    user.SetName('DeWitt')
    self.assertEqual('DeWitt', user.GetName())
    user.SetScreenName('dewitt')
    self.assertEqual('dewitt', user.GetScreenName())
    user.SetDescription('Indeterminate things')
    self.assertEqual('Indeterminate things', user.GetDescription())
    user.SetLocation('San Francisco, CA')
    self.assertEqual('San Francisco, CA', user.GetLocation())
    user.SetProfileImageUrl('http://twitter.com/system/user/profile_im'
                            'age/673483/normal/me.jpg')
    self.assertEqual('http://twitter.com/system/user/profile_image/673'
                     '483/normal/me.jpg', user.GetProfileImageUrl())
    user.SetStatus(self._GetSampleStatus())
    self.assertEqual(4212713, user.GetStatus().id) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:21,代码来源:twitter_test.py

示例3: testProperties

# 需要导入模块: import twitter [as 别名]
# 或者: from twitter import com [as 别名]
def testProperties(self):
    '''Test all of the twitter.User properties'''
    user = twitter.User()
    user.id = 673483
    self.assertEqual(673483, user.id)
    user.name = 'DeWitt'
    self.assertEqual('DeWitt', user.name)
    user.screen_name = 'dewitt'
    self.assertEqual('dewitt', user.screen_name)
    user.description = 'Indeterminate things'
    self.assertEqual('Indeterminate things', user.description)
    user.location = 'San Francisco, CA'
    self.assertEqual('San Francisco, CA', user.location)
    user.profile_image_url = 'http://twitter.com/system/user/profile_i' \
                             'mage/673483/normal/me.jpg'
    self.assertEqual('http://twitter.com/system/user/profile_image/6734'
                     '83/normal/me.jpg', user.profile_image_url)
    self.status = self._GetSampleStatus()
    self.assertEqual(4212713, self.status.id) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:21,代码来源:twitter_test.py

示例4: linkedinCallback

# 需要导入模块: import twitter [as 别名]
# 或者: from twitter import com [as 别名]
def linkedinCallback():

    print 'linkedinCallback'

    token = request.args['code']

    #print request.args

    print token
    cmd = './extensions/convert/convert_linkedin.py -u "https://www.linkedin.com/xxx/4a-games" -q "" -t "' + token + '"'

    print cmd
    msg = subprocess.check_output(cmd, shell=True)

    print msg


    return ''



# same path as on application settings page 
开发者ID:wowdd1,项目名称:xlinkBook,代码行数:24,代码来源:app.py

示例5: get_tweet_id

# 需要导入模块: import twitter [as 别名]
# 或者: from twitter import com [as 别名]
def get_tweet_id(url: str) -> Optional[str]:
    parsed_url = urllib.parse.urlparse(url)
    if not (parsed_url.netloc == 'twitter.com' or parsed_url.netloc.endswith('.twitter.com')):
        return None
    to_match = parsed_url.path
    # In old-style twitter.com/#!/wdaher/status/1231241234-style URLs,
    # we need to look at the fragment instead
    if parsed_url.path == '/' and len(parsed_url.fragment) > 5:
        to_match = parsed_url.fragment

    tweet_id_match = re.match(r'^!?/.*?/status(es)?/(?P<tweetid>\d{10,30})(/photo/[0-9])?/?$', to_match)
    if not tweet_id_match:
        return None
    return tweet_id_match.group("tweetid") 
开发者ID:zulip,项目名称:zulip,代码行数:16,代码来源:__init__.py

示例6: get_actual_image_url

# 需要导入模块: import twitter [as 别名]
# 或者: from twitter import com [as 别名]
def get_actual_image_url(self, url: str) -> str:
        # Add specific per-site cases to convert image-preview urls to image urls.
        # See https://github.com/zulip/zulip/issues/4658 for more information
        parsed_url = urllib.parse.urlparse(url)
        if (parsed_url.netloc == 'github.com' or parsed_url.netloc.endswith('.github.com')):
            # https://github.com/zulip/zulip/blob/master/static/images/logo/zulip-icon-128x128.png ->
            # https://raw.githubusercontent.com/zulip/zulip/master/static/images/logo/zulip-icon-128x128.png
            split_path = parsed_url.path.split('/')
            if len(split_path) > 3 and split_path[3] == "blob":
                return urllib.parse.urljoin('https://raw.githubusercontent.com',
                                            '/'.join(split_path[0:3] + split_path[4:]))

        return url 
开发者ID:zulip,项目名称:zulip,代码行数:15,代码来源:__init__.py

示例7: is_image

# 需要导入模块: import twitter [as 别名]
# 或者: from twitter import com [as 别名]
def is_image(self, url: str) -> bool:
        if not self.md.image_preview_enabled:
            return False
        parsed_url = urllib.parse.urlparse(url)
        # remove html urls which end with img extensions that can not be shorted
        if parsed_url.netloc == 'pasteboard.co':
            return False

        # List from https://support.google.com/chromeos/bin/answer.py?hl=en&answer=183093
        for ext in [".bmp", ".gif", ".jpe", "jpeg", ".jpg", ".png", ".webp"]:
            if parsed_url.path.lower().endswith(ext):
                return True
        return False 
开发者ID:zulip,项目名称:zulip,代码行数:15,代码来源:__init__.py

示例8: youtube_image

# 需要导入模块: import twitter [as 别名]
# 或者: from twitter import com [as 别名]
def youtube_image(self, url: str) -> Optional[str]:
        yt_id = self.youtube_id(url)

        if yt_id is not None:
            return f"https://i.ytimg.com/vi/{yt_id}/default.jpg"
        return None 
开发者ID:zulip,项目名称:zulip,代码行数:8,代码来源:__init__.py

示例9: vimeo_id

# 需要导入模块: import twitter [as 别名]
# 或者: from twitter import com [as 别名]
def vimeo_id(self, url: str) -> Optional[str]:
        if not self.md.image_preview_enabled:
            return None
        #(http|https)?:\/\/(www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|)(\d+)(?:|\/\?)
        # If it matches, match.group('id') is the video id.

        vimeo_re = r'^((http|https)?:\/\/(www\.)?vimeo.com\/' + \
                   r'(?:channels\/(?:\w+\/)?|groups\/' + \
                   r'([^\/]*)\/videos\/|)(\d+)(?:|\/\?))$'
        match = re.match(vimeo_re, url)
        if match is None:
            return None
        return match.group(5) 
开发者ID:zulip,项目名称:zulip,代码行数:15,代码来源:__init__.py

示例10: send_blacklisted_email

# 需要导入模块: import twitter [as 别名]
# 或者: from twitter import com [as 别名]
def send_blacklisted_email(app, username):
    if app.config.get('MAIL_SERVER', None):
        mail = Mail(app)
        body = render_template('access_denied.txt.j2', user=f"https://twitter.com/{username}")
        msg = Message(subject="moa access denied",
                      body=body,
                      recipients=[app.config.get('MAIL_TO', None)])

        try:
            mail.send(msg)

        except Exception as e:
            app.logger.error(e) 
开发者ID:foozmeat,项目名称:moa,代码行数:15,代码来源:helpers.py

示例11: _GetSampleUser

# 需要导入模块: import twitter [as 别名]
# 或者: from twitter import com [as 别名]
def _GetSampleUser(self):
    return twitter.User(id=718443,
                        name='Kesuke Miyagi',
                        screen_name='kesuke',
                        description=u'Canvas. JC Penny. Three ninety-eight.',
                        location='Okinawa, Japan',
                        url='http://twitter.com/kesuke',
                        profile_image_url='http://twitter.com/system/user/pro'
                                          'file_image/718443/normal/kesuke.pn'
                                          'g') 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:12,代码来源:twitter_test.py

示例12: testInit

# 需要导入模块: import twitter [as 别名]
# 或者: from twitter import com [as 别名]
def testInit(self):
    '''Test the twitter.User constructor'''
    user = twitter.User(id=673483,
                        name='DeWitt',
                        screen_name='dewitt',
                        description=u'Indeterminate things',
                        url='http://twitter.com/dewitt',
                        profile_image_url='http://twitter.com/system/user/prof'
                                          'ile_image/673483/normal/me.jpg',
                        status=self._GetSampleStatus()) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:12,代码来源:twitter_test.py

示例13: testEq

# 需要导入模块: import twitter [as 别名]
# 或者: from twitter import com [as 别名]
def testEq(self):
    '''Test the twitter.User __eq__ method'''
    user = twitter.User()
    user.id = 673483
    user.name = 'DeWitt'
    user.screen_name = 'dewitt'
    user.description = 'Indeterminate things'
    user.location = 'San Francisco, CA'
    user.profile_image_url = 'http://twitter.com/system/user/profile_image/67' \
                             '3483/normal/me.jpg'
    user.url = 'http://unto.net/'
    user.status = self._GetSampleStatus()
    self.assertEqual(user, self._GetSampleUser()) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:15,代码来源:twitter_test.py

示例14: testTwitterError

# 需要导入模块: import twitter [as 别名]
# 或者: from twitter import com [as 别名]
def testTwitterError(self):
    '''Test that twitter responses containing an error message are wrapped.'''
    self._AddHandler('http://twitter.com/statuses/public_timeline.json',
                     curry(self._OpenTestData, 'public_timeline_error.json'))
    # Manually try/catch so we can check the exception's value
    try:
      statuses = self._api.GetPublicTimeline()
    except twitter.TwitterError, error:
      # If the error message matches, the test passes
      self.assertEqual('test error', error.message) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:12,代码来源:twitter_test.py

示例15: testGetPublicTimeline

# 需要导入模块: import twitter [as 别名]
# 或者: from twitter import com [as 别名]
def testGetPublicTimeline(self):
    '''Test the twitter.Api GetPublicTimeline method'''
    self._AddHandler('http://twitter.com/statuses/public_timeline.json?since_id=12345',
                     curry(self._OpenTestData, 'public_timeline.json'))
    statuses = self._api.GetPublicTimeline(since_id=12345)
    # This is rather arbitrary, but spot checking is better than nothing
    self.assertEqual(20, len(statuses))
    self.assertEqual(89497702, statuses[0].id) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:10,代码来源:twitter_test.py


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