Python Forum

Full Version: ERROR NoneType object has no attribute content
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
We are creating a Virtual Scanner using Kali Linux, Metasploitable and PyCharm. I have been having problems with this code and the error message will be below the code.
#!/usr/bin/env python

import requests
from bs4 import BeautifulSoup


def request(url):
    try:
        return requests.get("http://10.0.2.20/mutillidae/index.php?page=dns-lookup.php" + url)
    except requests.exceptions.ConnectionError:
        pass


target_url = "http://10.0.2.20/mutillidae/index.php?page=dns-lookup.php"
response = request(target_url)

parsed_html = BeautifulSoup(response.content, features="html.parser")
forms_list = parsed_html.findAll("form")

# for form in forms_list:
#    action = form.get("action")
#    print(action)
#    method = form.get("method")
#    print(method)

#    inputs_list = form.findAll("input")
#    for input in inputs_list:
#        input_name = input.get("name")
#        print(input_name)
This is the error message I am getting
/root/PycharmProjects/Test2/venv/bin/python /root/PycharmProjects/Test2/test2.py
Traceback (most recent call last):
  File "/root/PycharmProjects/Test2/test2.py", line 17, in <module>
    parsed_html = BeautifulSoup(response.content, features="html.parser")
AttributeError: 'NoneType' object has no attribute 'content'

Process finished with exit code 1
I fixed the error above however now I ran into another error

#!/usr/bin/env python

import requests
from bs4 import BeautifulSoup
from urllib.parse import urlparse
#from urllib import parse as urlparse


def request(url):
    try:
        return requests.get("http://192.168.56.101/mutillidae/index.php?page=dns-lookup.php" + url)
    except requests.exceptions.ConnectionError:
        pass


target_url = "http://192.168.56.101/mutillidae/index.php?page=dns-lookup.php"
response = request(target_url)

parsed_html = BeautifulSoup(response.content, "html.parser")
forms_list = parsed_html.findAll("form")

for form in forms_list:
    action = form.get("action")
    post_url = urlparse.urljoin(target_url, action)
    print(post_url)
    method = form.get("method")
    print(method)

    inputs_list = form.findAll("input")
    for input in inputs_list:
        input_name = input.get("name")
        print(input_name)
This is the error that I am getting now

Traceback (most recent call last):
  File "extract_forms", line 5, in <module>
    from urllib.parse import urlparse
ImportError: No module named parse