Not sure why I am getting the error?
CodePudding user response:
Since you have the amazon_soup
used as an argument to the method and you use it as a variable which is undefined.
It should be:
print(getnextpage(geturl(amazon_url)))
The amazon_soup
variable you have declared is local to the method geturl
.
CodePudding user response:
The variable "amazon_soup" is not defined in the current context. In python, and in many other languages, the "level", in which you define a variable matters. This means that you cannot access it from outside of the "level" you are in. In your case, the variable is defined in a function and thus it cannot be access outside of this function. Change the code in line 4 to define amazon_soup at the start, the same way you did for amazon_url. So just add
amazon_soup = None
at the start of line 4. Then run line 4 and line 5.