scrape.nasdaq: Convert to BeautifulSoup v4
authorW. Trevor King <wking@tremily.us>
Sat, 16 Feb 2013 02:25:42 +0000 (21:25 -0500)
committerW. Trevor King <wking@tremily.us>
Sat, 16 Feb 2013 02:27:10 +0000 (21:27 -0500)
No change in the usage, except that the class attribute is now a list.

insider/scrape/nasdaq.py

index 5a1e616127d5a353b403ceea31ab33745a4b42df..0f49e87ac8ac55fa3690519450fc0371ba501ea0 100644 (file)
@@ -5,7 +5,7 @@ import datetime
 import decimal
 import urllib2
 
-from BeautifulSoup import BeautifulSoup
+from bs4 import BeautifulSoup
 
 from insider.models import add_transaction
 
@@ -68,7 +68,8 @@ def get_trades(ticker):
             elif field == '':
                 line_match = True
                 break  # we made it to the end of the list
-            if dict(tds[i].attrs).get('class', None) != class_:
+            classes = dict(tds[i].attrs).get('class', [])
+            if class_ and class_ not in classes:
                 break  # wrong class
             value = tds[i].text
             if class_ == 'Holdnum':  # decode numerical values