Python Forum
HTTP response capturing issue
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HTTP response capturing issue
#1
Hi All,

below script to download DSLAM configuration, getting "error a bytes-like object is required, not 'str' "
tried with encoding, still getting error

import os
import csv
import subprocess
import time
dslamUser = "admin"
dslamPass = "1234"
httpresponse = '200 OK'
with open('dslams.csv', 'r') as csvfile:
        x = csv.reader(csvfile, delimiter=',', quotechar='|')
        for row in x:
                dslam = list(row)
                dslamName = dslam[0].strip()
                dslamAddr = dslam[1].strip()
                print('Now Trying:{} IP:{}'.format(dslamName,dslamAddr))
                print ('Authenticating with DSLAM....')
                cmdargs = "--auth-no-challenge -t 5 --http-user=" + dslamUser + " --http-password=" + dslamPass + " http://" + dslamAddr + "/config-0_.dat -O /dev/null"
                data = ""
                while not ('200 OK') in data:
                      task = subprocess.Popen("wget " + cmdargs, shell=True, stdout=None, stderr=subprocess.PIPE)
                      time.sleep(3)
                      dummy, data = task.communicate()
                os.system("wget --auth-no-challenge -t 5 --http-user=" + dslamUser + " --http-password=" + dslamPass + " -O '" + dslamName + "_'`date +%Y%m%d%H%M`'.dat' http://" + dslamAddr + "/config-0_.dat")
Error:
Now Trying:24K_Glamore-1 IP:10.217.128.93 Authenticating with DSLAM.... Traceback (most recent call last): File "zyxelbackup.py", line 22, in <module> while not ('200 OK') in data: TypeError: a bytes-like object is required, not 'str'
Want to capture HTTP response

HTTP request sent, awaiting response... 200 OK
Reply


Messages In This Thread
HTTP response capturing issue - by anna - Mar-15-2019, 08:04 AM
RE: HTTP response capturing issue - by Larz60+ - Mar-15-2019, 01:59 PM
RE: HTTP response capturing issue - by Larz60+ - Mar-15-2019, 03:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Capturing BS4 values into DF and writing to CSV cubangt 18 2,028 Sep-05-2023, 01:57 PM
Last Post: cubangt
  capturing multiline output for number of parameters jss 3 853 Sep-01-2023, 05:42 PM
Last Post: jss
  Json filter is not capturing desired key/element mrapple2020 1 1,176 Nov-24-2022, 09:22 AM
Last Post: ibreeden
  ModuleNotFoundError: No module named 'http.client'; 'http' is not a package abhishek81py 1 15,580 Jun-25-2020, 08:58 AM
Last Post: buran
  Capturing inputs values from internal python script limors11 11 5,257 Jun-16-2019, 05:05 PM
Last Post: DeaD_EyE
  Capturing a snapshot from the video sreeramp96 1 2,199 May-24-2019, 07:02 AM
Last Post: heiner55
  httplib to http.client conversion issue zatlas1 1 2,621 Apr-12-2019, 05:21 PM
Last Post: Larz60+
  HTTP response capturing issue miunika 1 2,072 Mar-16-2019, 01:46 PM
Last Post: Larz60+
  HTTP 400 response code eshwinsukhdeve 1 1,760 Mar-03-2019, 06:11 PM
Last Post: Larz60+
  Capturing error from sql Grego 1 2,479 Jun-29-2018, 11:17 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020