I runned this python code in Pydev, and get NameError: name ‘Family’ is not defined.I don’t know why it happened. I didn’t even use the variable ‘Family’.
The python version is:Python 3.6.4 :: Anaconda, Inc.
Eclipse Java EE IDE for Web Developers.
Version: Oxygen.3a Release (4.7.3a)
Build id: 20180405-1200
OS: Windows 10, v.10.0, x86_64 / win32
import requests
import re
start_url=“https://basicenglishspeaking.com/daily-english-conversation-topics/”
mn = requests.get(start_url, timeout=30)
html = mn.text
pw = re.compile(r’\d{1,2}.\s<a\shref="https.*?</a>’)
urls = re.findall(pw, html)
for i in range(len(urls)):
key = eval(urls[i].split(’>’)[1].split(’<’)[0])
num = eval(urls[i].split(’.’)[0])
keys.append([key,num])
print(keys)
The error information:
Traceback (most recent call last):
File “C:\Users\JOY\eclipse-workspace\learn\spider\ces.py”, line 10, in
key = eval(urls[i].split(’>’)[1].split(’<’)[0])
File “”, line 1, in
NameError: name ‘Family’ is not defined