Last active
June 15, 2017 21:55
-
-
Save WDBell/1010de7fee6c604e00e80b52559ca424 to your computer and use it in GitHub Desktop.
Follow the price of apples
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
url = '''https://www.marketnews.usda.gov/mnp/fv-report-top-filters?&navClass=FRUITS&commAbr=APL&navType=byComm&repType=termPriceDaily&className=FRUITS&commName=%(commName)s&locName=&type=termPrice&repDate=%(theDate)s&endDate=%(theDate)s&format=excel&rebuild=false''' | |
import pendulum | |
from selenium import webdriver | |
commName = 'APPLES' | |
first_date = pendulum.parse('2017.6.13') | |
last_date = pendulum.parse('2017.6.17') | |
finish = last_date.add(days=+1) | |
day = first_date.add(days=-1) | |
if not(first_date.is_today() or first_date.is_past()): | |
print('request for future information') | |
driver = webdriver.Chrome() | |
while True: | |
day = day.add(days=+1) | |
if day == last_date: break | |
if day.is_weekend(): continue | |
theDate = day.strftime('%m%%2F%d%%2F%Y') | |
driver.get(url % locals()) | |
driver.quit() |
When I run the code, all it downloads is a 0bytes document "d64e048c-d12e-4a8a-b9b1-500cf3141117.tmp"
Any explanation why this is happening?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi again Bill, so I am trying to understand the code here. What this code is trying to do is to obtain a url that would download all the Excel files that belong to the date range I state as first_date and last_date?