My case is similar to connect Google.com by python 'telnetlib'
With python Anaconda 2.7.10 shell I have the blow script that works well:
HOST ="www.google.com"
tn=telnetlib.Telnet(HOST,"80")
tn.write("GET /index.html HTTP/1.1\nHost:"+HOST+"\n\n")
l=tn.read_all()
print(l)
which gives back:
HTTP/1.1 302 Found
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Referrer-Policy: no-referrer
Location: http://www.google.it/index.html?
gfe_rd=cr&dcr=0&ei=A7KiWv_2G6fCXojstrAO
Content-Length: 276
Date: Fri, 09 Mar 2018 16:10:43 GMTenter code here
If I now move to Python Anaconda 3.6.3 the same script as above I have the below error:
Traceback (most recent call last):
File "<ipython-input-4-0f3256299055>", line 3, in <module>
tn.write("GET /index.html HTTP/1.1\nHost:"+HOST+"\n\n")
File "C:\Users\FP\Anaconda3\lib\telnetlib.py", line 287, in write
if IAC in buffer:
TypeError: 'in <string>' requires string as left operand, not bytesenter code here
Do you have a suggestions for this ? I red some documentation about the telnetlib but so far did not yet come to a solution :-(. Any idea about what I might try to do ?
Thank you so much ! Fabio.