0

My program keeps showing this error raw_input is not defined whenever I use raw_input:

import urllib
from bs4 import BeautifulSoup
url = raw_input('http://py4e-data.dr-chuck.net/known_by_Eqlaas.html: ')
count = int(raw_input("Enter count: "))
position = int(raw_input("Enter position:"))
for i in range(count):
    html = urllib.urlopen(url).read()
    soup = BeautifulSoup(html)

    tags = soup('a')
    s = []
    t = []
    for tag in tags:
        x = tag.get('href', None)
        s.append(x)
        y = tag.text
        t.append(y)

    print (s[position-1])
    print (t[position-1])
    url = s[position-1]
1

2 Answers 2

4

Starting with Python 3, raw_input() was renamed to input().

Sign up to request clarification or add additional context in comments.

Comments

1

Since you are using python3, you have to replace

count = int(raw_input("Enter count: "))
position = int(raw_input("Enter position:"))

with

count = int(input("Enter count: "))
position = int(input("Enter position:"))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.