Skip to content

Commit

Permalink
Abstracted the main code into a module-friendly function
Browse files Browse the repository at this point in the history
  • Loading branch information
lamoni committed Jul 5, 2016
1 parent fa71751 commit 479142d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions juniper-support-scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,13 @@ def getDownloadLink(content):
def getFilename(input_url):
return basename(urlparse(input_url).path)

# Main
def main():
args = argsInit()

def scrape(url, username, password):
storage = StringIO()
clearCookies()

# 1. Get initial page so our cookies get set
executeCurl(args.url)
executeCurl(url)

# 2. Send login credentials
executeCurl(
Expand All @@ -87,8 +86,8 @@ def main():
'HiddenURI': '',
'LOCALE': 'en_us',
'AUTHMETHOD': 'UserPassword',
'username': args.username,
'password': args.password
'username': username,
'password': password

}
)
Expand All @@ -97,7 +96,7 @@ def main():
executeCurl(
input_url="https://webdownload.juniper.net/swdl/dl/download",
params={
'recordId': getRecordID(args.url),
'recordId': getRecordID(url),
'siteId': '1',
'eulaAccepted': 'Yes'
},
Expand All @@ -122,5 +121,10 @@ def main():

print "Done"

# Main
def main():
args = argsInit()
scrape(args.url, args.username, args.password)

if __name__ == "__main__":
main()

0 comments on commit 479142d

Please sign in to comment.