Esempio n. 1
0
 def test_from_string(self):
     string = "fasfdaf ewrawekljf jslkfdjas https://www.revealnews.org/article/a-brief-history-of-the-modern-strawberry/ fjasl;fkdjasl;kfdjasf"
     out = url.from_string(string, dedupe=False)
     assert (
         "https://www.revealnews.org/article/a-brief-history-of-the-modern-strawberry/"
         in out)
     assert (len(out) == 1)
Esempio n. 2
0
    def links(self):
        """
        Extract all links
        """
        urls = []
        if self.post.get('link'):
            urls.append(self.post['link'])

        if self.post.get('source'):
            urls.append(self.post['source'])

        if self.post.get('message'):
            msg_urls = url.from_string(self.post['message'])
            urls.extend(msg_urls)

        if self.post.get('descrption'):
            desc_urls = url.from_string(self.post['message'])
            urls.extend(desc_urls)

        return uniq(urls)
Esempio n. 3
0
    def links(self):
        """
        Extract all links
        """
        urls = []
        if self.post.get('link'):
            urls.append(self.post['link'])

        if self.post.get('source'):
            urls.append(self.post['source'])

        if self.post.get('message'):
            msg_urls = url.from_string(self.post['message'])
            urls.extend(msg_urls)

        if self.post.get('descrption'):
            desc_urls = url.from_string(self.post['message'])
            urls.extend(desc_urls)

        return uniq(urls)
Esempio n. 4
0
 def test_from_string_short_url(self):
     string = "fasf bit.ly/342fdasfa fdjasf http://bit.ly/3fs24dsfa sub.bit.ly/342fs4dsfa! foo.bit.ly/342fs4dsfa"
     out = url.from_string(string)
     assert(
         'bit.ly/342fdasfa' in out and 'http://bit.ly/3fs24dsfa' in out and 'sub.bit.ly/342fs4dsfa' in out and 'foo.bit.ly/342fs4dsfa' in out)
Esempio n. 5
0
 def test_from_string(self):
     string = "fasfdaf ewrawekljf jslkfdjas https://www.revealnews.org/article/a-brief-history-of-the-modern-strawberry/ fjasl;fkdjasl;kfdjasf"
     out = url.from_string(string, dedupe=False)
     assert(
         "https://www.revealnews.org/article/a-brief-history-of-the-modern-strawberry/" in out)
     assert(len(out) == 1)
Esempio n. 6
0
 def test_from_string_short_url(self):
     string = "fasf bit.ly/342fdasfa fdjasf http://bit.ly/3fs24dsfa sub.bit.ly/342fs4dsfa! foo.bit.ly/342fs4dsfa"
     out = url.from_string(string)
     assert ('bit.ly/342fdasfa' in out and 'http://bit.ly/3fs24dsfa' in out
             and 'sub.bit.ly/342fs4dsfa' in out
             and 'foo.bit.ly/342fs4dsfa' in out)