Ask coding questions

← Back to all posts
i need help on getting this program working
Edthehombre (0)

i need help with my program as i am getting this error

Traceback (most recent call last):
File "main.py", line 143, in <module>
button1 = tk.Button(text="CRAWL", command=Crawling)
NameError: name 'Crawling' is not defined

and im not sure on how to solve it

Answered by ch1ck3n (1632) [earned 5 cycles]
View Answer
Comments
hotnewtop
ch1ck3n (1632)

change Crawling to CRAW.Crawling

Edthehombre (0)

@ch1ck3n thank you this solved the problem. Would you happen to know how to take the data printed and transform it into a .csv file?

ch1ck3n (1632)

@Edthehombre In python, if you print the data, what would It show up as? I need to know to answer the question. :D

ch1ck3n (1632)

@Edthehombre Also if the answer helped please click the checkmark next to my name :)

Edthehombre (0)

@ch1ck3n how would you check that? unless you mean the data is just printed as words.

ch1ck3n (1632)

@ch1ck3n

I mean if the data is like data = ["https://google.com", "https://replit.com", "https://youtube.com"]

you can do

export = ""
for item in data:
  export += item + ","
Edthehombre (0)

@ch1ck3n well i did (print(type(x)) and the data came out as [] [] that

Edthehombre (0)

@ch1ck3n oh i checked and the data comes out as a list

ch1ck3n (1632)

@Edthehombre then my code should for above :D

Edthehombre (0)

@ch1ck3n im not quite sure how to implement this into my code

ch1ck3n (1632)

@Edthehombre You should add it to where it finished the crawling

Edthehombre (0)

@ch1ck3n
what would i replace the item in data with. because it just gives this error

ch1ck3n (1632)

@Edthehombre put it outside of the for loop

Edthehombre (0)

@ch1ck3n still not sure what to do here

ch1ck3n (1632)

@ch1ck3n The output should be at export.csv

Edthehombre (0)

@ch1ck3n hey thank you so much it works perfectly now, im just wondering if you also know how to sort the data. so when i press a button it will sort it by e.g. title or price

ch1ck3n (1632)

@Edthehombre just put end = end.sort(key=lambda x : x["price"]) right before line 33

ch1ck3n (1632)

@ch1ck3n that'll sort by price

Edthehombre (0)

@ch1ck3n would you be able to change that to another variable by the click of a button? so that the user can decide what they want to sort the data by

ch1ck3n (1632)

@Edthehombre Well, it's your project, why don't you do it? ;)

Edthehombre (0)

@ch1ck3n not quite sure how to go about it XD