0

When I run the first function it prints the correct URL. However, when I run the second section it shows an error saying that fullurl is not defined.

Can anyone help me with this?

Here is my code:

def urlmaker(format_mtg):
    fullurl = url + format_mtg.get() + "-constructed-league-" + date.get() #adds the users options to the url
    print(fullurl)
    return fullurl

def htmltotxt(fullurl):
    print(fullurl)
    response = urllib.request.urlopen(fullurl) #requests the ability to open the website, which magic.wizards.com allows
    html = response.read() #reads the html data from the open website
    html = str(html) #saves the data as a string
    make_lists(card_name_regex, card_number_regex, card_number_list, html)
3
  • 5
    Please use spaces. Python does not charge per character. Commented Feb 15, 2017 at 10:23
  • Also, show the actual full error and traceback. Nothing in the code you have posted would give that error. Commented Feb 15, 2017 at 10:24
  • 2
    You haven't shown how you call these functions. Please include that too. Also, please check your indentation. Commented Feb 15, 2017 at 10:26

1 Answer 1

1

Your code without comments and with proper indentation and spacing:

def urlmaker(format_mtg):
    fullurl = url + format_mtg.get() + "-constructed-league-" + date.get()
    print(fullurl)
    return fullurl

def htmltotxt(fullurl):
    print(fullurl)
    response = urllib.request.urlopen(fullurl)
    html = response.read()
    html = str(html)
    make_lists(card_name_regex, card_number_regex, card_number_list, html)
  1. Paste the necessary imports (the ones that are used in the shown code), at least urllib should be imported.
  2. You are using 5 variables that we don't know: url, date, card_name_regex, card_number_regex, card_number_list. date may not even be a variable but something imported. Define their values or give an example value so that we can reproduce your errors.
  3. You are not showing how you call your functions, so we don't know the values of the format_mtg and fullurl arguments. I can deduce that you are using the result from the first function as an argument for the second but still measing format_mtg.
  4. Paste the exception you are getting so that we can help you.

Without those 4 things, we can't find your problem.

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

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.