Created
April 29, 2015 15:22
-
-
Save ijharulislam/0979d84662c2b6f7c177 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __name__ == "__main__": | |
reload(sys) | |
sys.setdefaultencoding("utf-8") | |
import csv | |
import urllib2 | |
import sys | |
from bs4 import BeautifulSoup | |
if __name__ == "__main__": | |
reload(sys) | |
sys.setdefaultencoding("utf-8") | |
page = urllib2.urlopen('http://www.att.com/shop/wireless/devices/smartphones.html').read() | |
soup = BeautifulSoup(page) | |
soup.prettify() | |
for anchor in soup.findAll('a', {"class": "clickStreamSingleItem"}): | |
print anchor['title'] | |
with open('Smartphones.csv', 'wb') as csvfile: | |
spamwriter = csv.writer(csvfile, delimiter=',') | |
spamwriter.writerow([(anchor['title'])]) | |
with open('Smartphones.csv', 'wb') as csvfile: | |
spamwriter = csv.writer(csvfile, delimiter=',') | |
for anchor in soup.findAll('a', {"class": "clickStreamSingleItem"}): | |
print anchor['title'] | |
spamwriter.writerow([anchor['title'].encode('utf8')]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment