Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- """ Your mission should you choose to accept it:... use urllib() module to
- scrape daily summay page source of stock symbols. write() the source pages
- to local files until the list len() is reached. These files can later be
- read() into other regex() modules or scapy() for raw data extraction
- Future steps---->read() a symbol list from a file or user inputed list
- ---->regex() module to pluck out some image/graph data"""
- import sys
- import os
- import re
- import urllib
- def urldog():
- symbolslist = ["appl","goog","csco","intel","spy","fb"]
- i=0
- while i<len(symbolslist):
- urlScrape = "http://finance.yahoo.com/q?s=" + symbolslist[i]+"&ql=1"
- uf = urllib.urlopen(urlScrape)
- x = uf.read()
- f = open("goodies"+str(i)+".html","w")
- f.write(x)
- f.close()
- uf.close()
- i+=1
- print "The Url's of entered stock sympols have been scraped and saved to goodie.html files"
- print "These files can be later read into a regex or scapy module for data extraction. "
- # set up main
- def main():
- urldog()
- #call main
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment