You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-22Lines changed: 28 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -16,37 +16,43 @@ installation
16
16
usage
17
17
-----
18
18
19
-
>>> from ttp import ttp
20
-
>>> p = ttp.Parser()
21
-
>>> result = p.parse("@burnettedmond, you now support #IvoWertzel's tweet parser! https://github.com/edburnett/")
22
-
>>> result.reply
23
-
'burnettedmond'
24
-
>>> result.users
25
-
['burnettedmond']
26
-
>>> result.tags
27
-
['IvoWertzel']
28
-
>>> result.urls
29
-
['https://github.com/burnettedmond/']
30
-
>>> result.html
31
-
u'<a href="http://twitter.com/burnettedmond">@burnettedmond</a>, you now support <a href="https://twitter.com/search?q=%23IvoWertzel">#IvoWertzel</a>\'s tweet parser! <a href="https://github.com/edburnett/">https://github.com/edburnett/</a>'
19
+
```python
20
+
>>>from ttp import ttp
21
+
>>> p = ttp.Parser()
22
+
>>> result = p.parse("@burnettedmond, you now support #IvoWertzel's tweet parser! https://github.com/edburnett/")
23
+
>>> result.reply
24
+
'burnettedmond'
25
+
>>> result.users
26
+
['burnettedmond']
27
+
>>> result.tags
28
+
['IvoWertzel']
29
+
>>> result.urls
30
+
['https://github.com/burnettedmond/']
31
+
>>> result.html
32
+
u'<a href="http://twitter.com/burnettedmond">@burnettedmond</a>, you now support <a href="https://twitter.com/search?q=%23IvoWertzel">#IvoWertzel</a>\'s tweet parser! <a href="https://github.com/edburnett/">https://github.com/edburnett/</a>'
33
+
```
32
34
33
35
If you need different HTML output just subclass and override the `format_*` methods.
34
36
35
37
You can also ask for the span tags to be returned for each entity:
36
38
37
-
>>> p = ttp.Parser(include_spans=True)
38
-
>>> result = p.parse("@burnettedmond, you now support #IvoWertzel's tweet parser! https://github.com/edburnett/")
39
-
>>> result.urls
40
-
[('https://github.com/burnettedmond/', (57, 87))]
39
+
```python
40
+
>>> p = ttp.Parser(include_spans=True)
41
+
>>> result = p.parse("@burnettedmond, you now support #IvoWertzel's tweet parser! https://github.com/edburnett/")
42
+
>>> result.urls
43
+
[('https://github.com/burnettedmond/', (57, 87))]
44
+
```
41
45
42
46
43
47
To use the shortlink follower (depends on the [Requests](http://docs.python-requests.org/) library):
44
48
45
-
>>> from ttp import utils
46
-
>>> # assume that result.urls == ['http://t.co/8o0z9BbEMu', u'http://bbc.in/16dClPF']
47
-
>>> print utils.follow_shortlinks(result.urls) # pass in list of shortlink URLs
0 commit comments