Advertisement
Guest User

Untitled

a guest
Jul 30th, 2017
661
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. # File: test.py THIS WORKS!!!!!!! 170730.1257
  2. # Art Du Rea and Roger Shruber Copyright (c) 2017 - All rights reserved
  3. #
  4. # Without Mr. Shruber's assistance, this would have been a real struggle!
  5. # My most sincere appreciation to his skills with Python Requests and
  6. # especially with browser "Developer" tools, about which, before yesterday,
  7. # I knew ABSOLUTELY NOTHING. Thanks for his great mentoring!
  8. #
  9. # cd /media/mint/artwork/ArtWork/web-scraper
  10.  
  11. print 'Test Scraper - IT WORKS!'
  12.  
  13. # obfuscate the login terms
  14. import sys
  15. sys.path[0] = '/media/mint/artwork/ArtWork/web-scraper'
  16. import account
  17. # account.myact() returns 'myusername' or the REAL username
  18. # account.mypwd() returns 'mypassword' or the REAL password
  19.  
  20. import requests
  21. login_url = 'http://192.168.0.1/login.cgi'
  22. payload = {'loginSubmitValue':'1','admin_username':account.myact(),'admin_password':account.mypwd()}
  23. data_url = 'http://192.168.0.1/GetDSLInfo.cgi'
  24.  
  25. s = requests.Session()
  26. resp = s.post(login_url, data=payload)
  27. print resp
  28. # <Response [200]>
  29. print resp.text
  30. test = s.get(data_url)
  31. print test.text
  32.  
  33. # OUTPUT !!!!!!! All of the current DSL Status page display values
  34. # ==============
  35. # CONNECTED||CONNECTED||20.44||0.892||ALL||ADSL_2plus||10H:24M:59S||
  36. # 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||
  37. # 1985982||1581244||290||0||1333.161||0.000||
  38. #
  39. # THIS IS MY TOTAL USAGE VALUE !!!! Megabits - I CAN parse this EASILY!!!
  40. # 17091.326||
  41. #
  42. # 0.000||0||0||Interleaved||Interleaved||290||0||0||0||79881||124||5||0
  43.  
  44.  
  45. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  46. Log of Terminal Session output:
  47. ===============================
  48.  
  49. mint@mint /media/mint/artwork/ArtWork/web-scraper $ python test.py
  50. Test Scraper - IT WORKS!
  51. <Response [200]>
  52. <head>
  53. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  54. <meta http-equiv="If-Modified-Since" CONTENT="0">
  55. <meta http-equiv="Cache-Control" CONTENT="no-cache">
  56. <meta http-equiv="Pragma" CONTENT="no-cache">
  57. <meta http-equiv="Expires" CONTENT="0">
  58. <script language="javascript">
  59. window.parent.location.href="index.cgi";
  60. </script>
  61. </head>
  62.  
  63. 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
  64.  
  65.  
  66. mint@mint /media/mint/artwork/ArtWork/web-scraper $
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement