download html works!
This commit is contained in:
parent
e6fc19ca0d
commit
9832e77ba3
1 changed files with 9 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import requests
|
import requests, urllib, os
|
||||||
|
|
||||||
#### FIRST THREE YEARS 2010/2011/2012 ARE DIFFERENT WAYS TO RETRIEVE THAN 13-17
|
#### FIRST THREE YEARS 2010/2011/2012 ARE DIFFERENT WAYS TO RETRIEVE THAN 13-17
|
||||||
|
|
||||||
|
@ -41,6 +41,13 @@ class Old_Stats:
|
||||||
link_list.append('http://' + self.base_urls()[url_step].replace(self.sport_url, '') + '/' + link.get('href'))
|
link_list.append('http://' + self.base_urls()[url_step].replace(self.sport_url, '') + '/' + link.get('href'))
|
||||||
return link_list
|
return link_list
|
||||||
|
|
||||||
|
def download_html_links(self):
|
||||||
|
for url_step in range(0, len(self.get_box_score_links()) + 1):
|
||||||
|
filename = 'box_score' + str(url_step) + '.htm'
|
||||||
|
response = requests.get(self.get_box_score_links()[url_step])
|
||||||
|
with open('./data/' + filename, "wb") as code:
|
||||||
|
code.write(response.content)
|
||||||
|
|
||||||
old_stats = Old_Stats()
|
old_stats = Old_Stats()
|
||||||
|
|
||||||
print old_stats.get_box_score_links()
|
old_stats.download_html_links()
|
||||||
|
|
Loading…
Add table
Reference in a new issue