Our first script

Let's start programming in Python. In this first example, we'll perform a GET request using Python and the requests library:

  1. Let's open the Atom editor in the Virtual Machine and create a new file by navigating to File | New File.
  2. We'll import the requests library to start with. This can be done by typing import requests.
  3. Now, we need to create a variable R, where we'll instantiate a requests object with the GET method, and the target URL in this case is httpbin.org/ip:
import requestsr=requests.get('http://httpbin.org/ip')
  1. Finally, we print the content of the response using print r.text.
  2. Save the file in the /Examples/Section-2 folder as Chapter-3.py.
  3. Let's run it on the Terminal. Open the Terminal and change the directory ...

Get Learning Python Web Penetration Testing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.