Python Forum
ERROR NoneType object has no attribute content
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ERROR NoneType object has no attribute content
#1
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
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  AttributeError: 'str' object has no attribute 'size' russoj5 4 7,488 Nov-15-2020, 11:43 PM
Last Post: deanhystad
  Object has no attribute 'replaceall' ? peterp 2 7,201 Nov-10-2020, 09:23 PM
Last Post: buran
  Calling an class attribute via a separate attribute in input wiggles 7 2,887 Apr-04-2020, 10:54 PM
Last Post: wiggles
  AttributeError: 'list' object has no attribute 'g_s' NitinL 6 3,390 Mar-31-2020, 10:24 AM
Last Post: pyzyx3qwerty
  Attribute error in code 3DEN 1 2,407 Dec-09-2019, 10:43 AM
Last Post: buran
  Attribute Error DiceMann 1 1,921 Nov-01-2019, 06:54 AM
Last Post: buran
  AttributeError: 'tuple' object has no attribute 'move' senfik99 2 4,042 Feb-26-2019, 12:42 PM
Last Post: stullis
  Integer object error Zatoichi 2 3,740 Feb-18-2018, 07:25 AM
Last Post: Zatoichi
  text = str(text.encode('utf-8')) AttributeError: 'float' object has no attribute 'enc ulrich48155 2 8,753 Jul-31-2017, 05:21 PM
Last Post: ulrich48155
  error 'ring' is not a callable object JakeWitten 1 3,066 May-02-2017, 05:09 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

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