Web Client Programming with Perl-Chapter 7: Graphical Examples with Perl/Tk- P2

Tham khảo tài liệu 'web client programming with perl-chapter 7: graphical examples with perl/tk- p2', công nghệ thông tin, quản trị web phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 7 Graphical Examples with Perl Tk- P2 The do_search function will take an optional url argument to give it an alternative place to connect to. Otherwise it expects word to contain something. We just hit Return from the entry widget so word contains the string example and url is undefined. If we accidentally hit Return before typing anything we don t want to search for a nonstring so we return from the subroutine if that s the case INFORMATION Connect url text- configure -cursor watch mw- idletasks We give the user some feedback by placing along the bottom of the application a Connect. string and we also change the cursor to a watch. mw- idletasks just tells the window to do anything it was waiting to do so that we can actually see the watch and information string my request new HTTP Request GET url my response ua- request request if response- is_error INFORMATION ERROR Could not retrieve url elsif response- is_success my html parse_html response- content Clear out text item text- configure -state normal text- delete end html- traverse display_html text- configure -state disabled html_text INFORMATION Done text- configure -cursor top_left_arrow Next we try to connect to the url. If we fail the program should display a simple error message in the information area. If we succeed then we want to get the actual document out and parse it. html will contain the HTML tree object. We reconfigure the text object to normal so that we can place text in it 5 delete anything that might have been there previously and then call traverse for the HTML object telling traverse to call display_html for each item . After the entire document has been traversed we ll see what that does in a minute we re-disable the text widget and declare ourselves done for that particular word lookup. Our function display_html gets called with three arguments a node pointer a startflag flag and the depth we are into the tree. We only care about the first two arguments since they will help us

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
8    75    1    28-03-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.