當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。