SHARE
TWEET

Untitled

a guest Aug 12th, 2017 53 in 22 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. url = '...'
  2. comments = []
  3. while(url):
  4.     html = urlopen(url)
  5.     soup = BeautifulSoup(html, 'html.parser')
  6.     for c in soup.select('p.comText'):
  7.         comments.append(c.text)
  8.     prev = soup.select('li.prev a')
  9.     url = prev[0].get('href') if prev else None
  10. with open('comments.csv', 'w') as f:
  11.     import csv
  12.     wr = csv.writer(f, quoting=csv.QUOTE_ALL, delimiter='\n')
  13.     wr.writerow(comments)
RAW Paste Data
Top