Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # File: test.py THIS WORKS!!!!!!! 170730.1257
- # Art Du Rea and Roger Shruber Copyright (c) 2017 - All rights reserved
- #
- # Without Mr. Shruber's assistance, this would have been a real struggle!
- # My most sincere appreciation to his skills with Python Requests and
- # especially with browser "Developer" tools, about which, before yesterday,
- # I knew ABSOLUTELY NOTHING. Thanks for his great mentoring!
- #
- # cd /media/mint/artwork/ArtWork/web-scraper
- print 'Test Scraper - IT WORKS!'
- # obfuscate the login terms
- import sys
- sys.path[0] = '/media/mint/artwork/ArtWork/web-scraper'
- import account
- # account.myact() returns 'myusername' or the REAL username
- # account.mypwd() returns 'mypassword' or the REAL password
- import requests
- login_url = 'http://192.168.0.1/login.cgi'
- payload = {'loginSubmitValue':'1','admin_username':account.myact(),'admin_password':account.mypwd()}
- data_url = 'http://192.168.0.1/GetDSLInfo.cgi'
- s = requests.Session()
- resp = s.post(login_url, data=payload)
- print resp
- # <Response [200]>
- print resp.text
- test = s.get(data_url)
- print test.text
- # OUTPUT !!!!!!! All of the current DSL Status page display values
- # ==============
- # CONNECTED||CONNECTED||20.44||0.892||ALL||ADSL_2plus||10H:24M:59S||
- # 2||1||0||0||0||0||94||0||0||ADSL||8/35||UBR|| 9.0| 11.7| 19.9| 12.0| 20.0| 12.4||
- # 1985982||1581244||290||0||1333.161||0.000||
- #
- # THIS IS MY TOTAL USAGE VALUE !!!! Megabits - I CAN parse this EASILY!!!
- # 17091.326||
- #
- # 0.000||0||0||Interleaved||Interleaved||290||0||0||0||79881||124||5||0
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Log of Terminal Session output:
- ===============================
- mint@mint /media/mint/artwork/ArtWork/web-scraper $ python test.py
- Test Scraper - IT WORKS!
- <Response [200]>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta http-equiv="If-Modified-Since" CONTENT="0">
- <meta http-equiv="Cache-Control" CONTENT="no-cache">
- <meta http-equiv="Pragma" CONTENT="no-cache">
- <meta http-equiv="Expires" CONTENT="0">
- <script language="javascript">
- window.parent.location.href="index.cgi";
- </script>
- </head>
- CONNECTED||CONNECTED||20.44||0.892||ALL||ADSL_2plus||10H:45M:40S||2||1||0||0||0||0||94||0||0||ADSL||8/35||UBR|| 9.0| 11.7| 19.9| 12.0| 20.0| 12.4||1990347||1584280||290||0||1376.659||0.000||17134.824||0.000||0||0||Interleaved||Interleaved||290||0||0||0||80265||126||0||0
- mint@mint /media/mint/artwork/ArtWork/web-scraper $
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement