Skip to content

Instantly share code, notes, and snippets.

@showyou
Created February 15, 2010 07:29
Show Gist options
  • Select an option

  • Save showyou/304465 to your computer and use it in GitHub Desktop.

Select an option

Save showyou/304465 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# togetter to txt convert
# using : python togetter2txt id
from BeautifulSoup import BeautifulSoup
import urllib
import sys
def togetter2txt(id):
f = urllib.urlopen("http://togetter.com/li/"+id)
data = f.read()
soup = BeautifulSoup(data)
for div in soup.findAll("div"):
if div.has_key('class'):
if div['class'] == "list_body":
print div.h5.a.string +":",
for a in div.h4.contents:
print a,
print ""
if __name__ == "__main__":
if len(sys.argv) < 2:
# for test
id = "5299"
else:
id = sys.argv[1]
togetter2txt(id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment