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)
SGhaleb
1,0031 gold badge14 silver badges31 bronze badges
asked Feb 15, 2017 at 10:23
dovefromhell
841 gold badge2 silver badges12 bronze badges
-
5Please use spaces. Python does not charge per character.Daniel Roseman– Daniel Roseman2017年02月15日 10:23:46 +00:00Commented 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.Daniel Roseman– Daniel Roseman2017年02月15日 10:24:34 +00:00Commented Feb 15, 2017 at 10:24
-
2You haven't shown how you call these functions. Please include that too. Also, please check your indentation.roganjosh– roganjosh2017年02月15日 10:26:49 +00:00Commented Feb 15, 2017 at 10:26
1 Answer 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)
- Paste the necessary imports (the ones that are used in the shown code), at least
urllibshould be imported. - You are using 5 variables that we don't know:
url,date,card_name_regex,card_number_regex,card_number_list.datemay not even be a variable but something imported. Define their values or give an example value so that we can reproduce your errors. - You are not showing how you call your functions, so we don't know the values of the
format_mtgandfullurlarguments. I can deduce that you are using the result from the first function as an argument for the second but still measingformat_mtg. - Paste the exception you are getting so that we can help you.
Without those 4 things, we can't find your problem.
answered Feb 15, 2017 at 10:42
Adirio
5,3041 gold badge18 silver badges27 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py