Hey, Jow Forums, i need some help with this python project im working on, from this book i bought on python

Hey, Jow Forums, i need some help with this python project im working on, from this book i bought on python.

Heres the code:

#!/usr/bin/env python

import socket

target_host = "www.google.com"
target_port = "80"

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM

client.connect ((target_host,target_port))

client.send("GET / HTTP/1.1\r\nhost: google.com\r\n\r\n")

response = client.recv(4096)

print response


anyway, its a simple quick and dirty TCP client, i keep getting the error from the interpreter


> client.connect ((target_host,target_port))
^
SyntaxError: invalid syntax


thanks in advance.

Attached: 8afa1643b907c743b2d48b173ad2c4b4a2a2f0cb_main_hero_image-1.jpg (630x473, 33K)

Close this damn parenthesis in a 5th line
BTW, python is weird

You don't have a closing bracket on the line above, so it's looking for args and you give it that so it thinks wtf is this.

Thx user.

I will pay you in bitcoin cash or PayPal to teach me the basic. Can you give me a throwaway email address to link up?

Ok, so now im getting this,

client.connect ((target_host,target_port))
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
TypeError: an integer is required

I'm sorry, but I don't actualy know Python, I don't particulary like this language
I know C and C++, a bit of webmastering (HTML+CSS+JS, little PHP) and little of some other languages
And come on, I don't want any money for advices

You have to give an IP addres to the function (e.g. 8.8.8.8), not the web address, this expects integer (number) as an input

BTW, if you're not using Windows, then use \n instead of \r\n

Im using ubuntu, but thx

This book is fucked.

So you should use the \n thing
\r\n is just another Windows oddity

What book do you use?
Also, is Python your first language?
Is this book really for beginners (dealing with sockets is not something newbies should be exposed to)?
Did you managed compiling and running your program?

Nah c++ is my first "Programming" laungauge, before that i learned both windows and Linux shell scripting,the book im using is "black hat python" by Justin seitz i have some minor experience with python with mostly writing to files and the like but really nothing like sockets.

and no im still getting errors even with the IP, ill figure it out eventually, i just gotta play around with it.

Sorry for I thought you are newbie
Maybe post your errors here so someone may find a way to fix them

yeah, even with c++ my knowledge is limited to i/o mostly cause thats what the program i started writting a while ago required it, now im working on the python scripts that the c++ program is supposed to print to another file, wish me luck.

Nice, I'm going to finish alpha version of my vocabulary builder program in C and then I guess I'll learn more about shell scripting, because I barely can use bash and my scripting abilities suck

>
oof are you self taught?

Yup, internet is you're friend
Just remember to not give up
Try spoj if you want to master your language (or to just get a little better)
I use it since recently, but it's very helpful

Nice thanks for the suggestion, i fuckin hate codeacademy, it hasnt really taught me shit, i learned what i know of c++ from sololearn through.

kek, it dosent help that i have a learning disability called "dyscalclia" which makes math very difficult.

Try multiple courses till you find the one that fits you, there is even one on wikibooks and there is this book about C language written by it's inventors
When you'll understand basics, just think about project you want to make, and then grasp more specific knowledge (like sockets, GUI programming, some other libraries)
And remember - stack exchange and Jow Forums are your friends
And having dyscalculia has to suck, but it doesn't prevent you from being a great coder

thx m8, for just not calling me a faggot.