1 00:00:06,200 --> 00:00:07,200 Are we good to go? 2 00:00:27,380 --> 00:00:33,520 Well, welcome to the session on the Introduction to Writing Spiders and Web Agents. 3 00:00:36,460 --> 00:00:37,180 We're going to be talking about the introduction to writing spiders and web agents. 4 00:00:37,200 --> 00:00:46,700 My challenge here today is that I've got, what, 45, 50 minutes to introduce the idea of writing agents and spiders. 5 00:00:48,760 --> 00:00:54,760 And so what I'm going to do here is I've got three main goals I want to accomplish here in this session. 6 00:00:55,420 --> 00:00:59,580 One of them is I want to convince you that writing these things is a worthwhile activity. 7 00:01:00,260 --> 00:01:04,860 Even if you don't do it professionally, and there are a lot of opportunities to do this kind of stuff professionally, 8 00:01:05,140 --> 00:01:07,120 it's just a really fun thing to do. 9 00:01:07,200 --> 00:01:12,880 I know a lot of people who maybe don't code as much as they'd like at work, 10 00:01:12,960 --> 00:01:15,180 and they get home and they've got this need to code, you know? 11 00:01:15,560 --> 00:01:21,880 So they do silly things like, you know, do a database that catalogs their CDs or something silly. 12 00:01:22,480 --> 00:01:25,400 You can have a lot more fun writing spiders and web agents, 13 00:01:25,480 --> 00:01:29,300 because once these things start moving, they just become kind of organic, 14 00:01:29,480 --> 00:01:35,440 especially when they interface with some very non-web kind of things like, you know, 15 00:01:35,440 --> 00:01:36,680 cell phones and printers. 16 00:01:37,200 --> 00:01:38,200 You know, fax machines and stuff. 17 00:01:38,300 --> 00:01:38,980 It can get very fun. 18 00:01:41,160 --> 00:01:48,280 The other goal I have is I want to get you guys thinking about ideas for spiders and web agents 19 00:01:48,280 --> 00:01:51,080 that you want to go off and design on your own. 20 00:01:51,460 --> 00:01:56,260 So I'm going to give some suggestions for ways of coming up with ideas. 21 00:01:56,860 --> 00:01:59,120 You know, it's easy to write a spider or an agent. 22 00:01:59,260 --> 00:02:03,980 The hard part is having a really great one that does something really cool. 23 00:02:04,340 --> 00:02:07,120 So hopefully I can kind of give you some ideas on how to come up with, 24 00:02:07,200 --> 00:02:07,400 you know, some ideas. 25 00:02:08,700 --> 00:02:11,940 The other thing I'm going to do is provide you with some basic technical skills. 26 00:02:13,220 --> 00:02:17,520 And pretty much all you really need to do these things is basic technical skills. 27 00:02:18,860 --> 00:02:23,880 There's so many great software available now that you can download to do wonderful things, 28 00:02:24,040 --> 00:02:25,280 and there's some great programming languages. 29 00:02:25,580 --> 00:02:27,840 So it's taken a lot of the mystery out of doing this. 30 00:02:28,040 --> 00:02:31,620 So a lot of it is just being introduced to how to do this kind of stuff. 31 00:02:32,140 --> 00:02:34,580 So I'm going to make some suggestions for programming languages, 32 00:02:35,060 --> 00:02:36,500 things that I've used in the past. 33 00:02:37,200 --> 00:02:40,420 Some downloading techniques, some parsing methods, 34 00:02:40,580 --> 00:02:44,380 things that I've discovered over the last, you know, three or four years. 35 00:02:45,060 --> 00:02:47,640 And ways of making fault-tolerant designs. 36 00:02:48,500 --> 00:02:54,400 You've got to keep in mind that unless you're spidering your own site or your own server 37 00:02:54,400 --> 00:02:59,620 or a known server, these things are going to change at the whim of whoever is the webmaster. 38 00:03:00,140 --> 00:03:05,240 So I'll give you some ideas for writing fault-tolerant spiders and web agents. 39 00:03:07,380 --> 00:03:08,320 Real quick bio. 40 00:03:08,460 --> 00:03:09,480 My name is Mike Schrenk. 41 00:03:09,920 --> 00:03:12,900 I am a freelance internet strategist and developer. 42 00:03:13,100 --> 00:03:16,900 I'm based in Minneapolis, but I work all over the place. 43 00:03:17,400 --> 00:03:20,760 The nice thing about being based in Minneapolis is that you're only like two, 44 00:03:20,920 --> 00:03:22,760 two and a half hours from anywhere in the country. 45 00:03:23,000 --> 00:03:25,960 The bad thing about being in Minneapolis is that you're two, 46 00:03:26,020 --> 00:03:27,980 two and a half hours from anything in the country, so. 47 00:03:31,420 --> 00:03:34,060 Spiders and agents are a large part of my business. 48 00:03:34,140 --> 00:03:35,280 They're not the only thing I do. 49 00:03:36,560 --> 00:03:37,180 I'm a developer. 50 00:03:37,200 --> 00:03:39,240 But I'm doing more and more of them as time goes on. 51 00:03:39,300 --> 00:03:42,920 People are seeing that you can do some really cool things. 52 00:03:43,060 --> 00:03:49,800 For example, I have one client that's basing their entire business on what I'm doing. 53 00:03:50,060 --> 00:03:55,520 And I've got others that see that they can get a real competitive advantage 54 00:03:56,160 --> 00:04:01,460 over their competitors by being able to know things before anybody else knows it. 55 00:04:01,880 --> 00:04:05,060 And then being able to act on it really, really quickly. 56 00:04:05,340 --> 00:04:07,180 So there's some real powerful things. 57 00:04:07,180 --> 00:04:09,240 There's a lot of things you can do here that make a lot of business sense. 58 00:04:09,860 --> 00:04:11,460 In addition to being a lot of fun to write. 59 00:04:13,620 --> 00:04:17,840 Okay, what's the connection between spiders and agents and hacking? 60 00:04:21,120 --> 00:04:27,600 The way I do it, it's the classic hacking activity if you belong to the MIT school of hacking. 61 00:04:28,880 --> 00:04:30,420 You break down technology. 62 00:04:30,800 --> 00:04:31,660 You grab something. 63 00:04:31,800 --> 00:04:32,520 You look at it. 64 00:04:32,560 --> 00:04:34,380 You figure out what it does, how it works. 65 00:04:35,040 --> 00:04:36,760 And then you recombine technology. 66 00:04:37,180 --> 00:04:40,280 You do something that was never intended by the original designers. 67 00:04:40,720 --> 00:04:44,000 So it's kind of the MacGyver approach to web development. 68 00:04:44,240 --> 00:04:48,000 You're taking things from all different places and doing really bizarre things. 69 00:04:49,020 --> 00:04:51,960 You can also do some things that are useful security things. 70 00:04:52,080 --> 00:04:52,980 Like you can monitor logs. 71 00:04:53,420 --> 00:04:55,700 You can look for unauthorized servers on a network. 72 00:04:55,940 --> 00:04:57,180 You can test system integrity. 73 00:04:57,380 --> 00:04:58,580 You can do all kinds of cool stuff like that. 74 00:05:01,180 --> 00:05:02,600 Okay, what is an agent? 75 00:05:03,200 --> 00:05:06,960 Real basically here, if you can think of a browser as being a very, 76 00:05:07,180 --> 00:05:12,940 very general purpose agent, and it's general purpose in the fact that basically you just 77 00:05:12,940 --> 00:05:15,620 point at some place and it goes there, okay? 78 00:05:16,300 --> 00:05:19,740 If that's all you do with the internet, you're really missing out on a lot of stuff. 79 00:05:19,920 --> 00:05:22,600 And I'll show you some examples of some stuff here in a bit. 80 00:05:25,680 --> 00:05:28,020 All agents work on a client-server relationship. 81 00:05:28,320 --> 00:05:30,120 So you've got, in this case, a browser. 82 00:05:30,280 --> 00:05:32,180 Sends out a request to some web server. 83 00:05:32,420 --> 00:05:36,680 It gets a response back, and generally the initial response is, 84 00:05:37,180 --> 00:05:40,600 um, some headers, HTTP headers that are sent back. 85 00:05:40,700 --> 00:05:41,720 We'll talk more about those later. 86 00:05:41,940 --> 00:05:43,260 And also some HTML. 87 00:05:46,340 --> 00:05:48,620 Now a client must ask for everything. 88 00:05:49,600 --> 00:05:57,760 So in other words, if you went to the, um, the old DEF CON page, there are nine separate images 89 00:05:57,760 --> 00:06:00,360 that are on that page in addition to the HTML. 90 00:06:00,620 --> 00:06:06,940 So after it receives the HTML page, it's got to send out requests for all those images and all those 91 00:06:06,940 --> 00:06:07,160 images. 92 00:06:07,160 --> 00:06:07,920 So let me just come back. 93 00:06:10,680 --> 00:06:12,440 What do spiders and agents do? 94 00:06:13,680 --> 00:06:16,880 Like I said earlier, this is not difficult stuff. 95 00:06:17,520 --> 00:06:22,700 They download data, they parse and filter data, and then they take some kind of action. 96 00:06:23,220 --> 00:06:27,600 And in all the examples I'm going to show you, pretty much they all do the exact same thing. 97 00:06:27,980 --> 00:06:31,840 Uh, what they download and what kind of action they take is entirely up to you. 98 00:06:32,540 --> 00:06:37,020 Um, when you're, when you're thinking about agents and spiders, don't, don't 99 00:06:37,020 --> 00:06:38,100 limit yourself to spiders. 100 00:06:38,800 --> 00:06:45,160 Spiders are just a general purpose, excuse me, they are a special purpose agent that acts specifically on links. 101 00:06:45,500 --> 00:06:50,480 So they're going, they'll grab a webpage, look for all the links, and then they'll, they'll, excuse me, 102 00:06:50,500 --> 00:06:57,180 they'll grab a webpage, look for information on that page, then gather up all the links, and then do the same thing 103 00:06:57,180 --> 00:06:57,840 in all those links. 104 00:06:59,040 --> 00:07:01,060 So don't limit yourself to spidering. 105 00:07:01,060 --> 00:07:03,760 That's only a tiny, tiny portion of what you can do with these things. 106 00:07:04,020 --> 00:07:06,900 Try to instead think about providing websites. 107 00:07:06,900 --> 00:07:08,200 Web services, okay? 108 00:07:08,600 --> 00:07:14,340 Now I think if you, if you think about web services, you know, you can still employ spiders if you want to in your services, 109 00:07:14,600 --> 00:07:21,660 but I think it gives you a, a little better framework to, to, to stand on when you're thinking about what kind of things you might want to do. 110 00:07:25,900 --> 00:07:27,560 Why write a spider or an agent? 111 00:07:28,540 --> 00:07:36,600 Well, like I said earlier, browsers are kind of dumb, you know, you point them in one direction, they'll go off, and they'll, they'll do it, and then they'll stop and wait for the next, 112 00:07:36,600 --> 00:07:37,020 next instruction. 113 00:07:37,960 --> 00:07:43,180 Well, with an agent or with a spider, you can automatically surf the web, which is very nice. 114 00:07:43,480 --> 00:07:46,780 You can also filter out information that you're not interested in. 115 00:07:47,820 --> 00:07:51,980 You can also download and repackage information for later non-web devices. 116 00:07:52,300 --> 00:08:06,140 So in other words, you could write a little deal that goes off to your favorite webpage, downloads it, and does clipping, and stores it in a, a manner that would be good for a PDA. 117 00:08:06,900 --> 00:08:09,700 Or you can send stuff off to printers or fax machines. 118 00:08:10,120 --> 00:08:19,600 The other reason you want to do agents and spiders is, especially if you're not interested in images, you can download stuff really, really quickly. 119 00:08:20,740 --> 00:08:23,080 So speed is a big, big advantage. 120 00:08:24,860 --> 00:08:26,980 Okay, where do project ideas come from? 121 00:08:29,580 --> 00:08:32,460 Think about areas where you can bridge things. 122 00:08:32,620 --> 00:08:34,900 In other words, I've got a bunch of stuff there. 123 00:08:34,940 --> 00:08:36,580 Everything from HTTP servers to, to, to, to, to, to, to, to, to, to, to. 124 00:08:36,600 --> 00:08:41,400 To computers, to phones, to webcams, to printers, instant messaging, fax machines. 125 00:08:42,000 --> 00:08:46,160 Think of instances where you would want to combine those types of things. 126 00:08:49,600 --> 00:08:55,400 Another thing to think about when you're looking for coming up with an idea for writing a spider and agents, look for things that you can automate. 127 00:08:56,000 --> 00:09:03,860 For example, there is a webpage called www.whois.net that is run by Network Solutions. 128 00:09:05,480 --> 00:09:16,100 And the really cool thing about this page is that if you're looking for, if you want to take out a domain name, instead of, you know, going to register.com or something and just typing in the name, oh, taken. 129 00:09:16,280 --> 00:09:16,860 How about this one? 130 00:09:16,960 --> 00:09:17,640 No, it's taken. 131 00:09:18,300 --> 00:09:19,340 It's not very effective. 132 00:09:19,480 --> 00:09:32,940 What you can do with whois.net is you can type in a word or a series of characters and it will return all of the domain names with that series of characters as a subset of the full name. 133 00:09:32,940 --> 00:09:38,860 So if you're looking, if you want to do a website, for example, on food or something, you can type in food. 134 00:09:39,100 --> 00:09:43,720 It will return all the domain names that have the word food in it. 135 00:09:43,920 --> 00:09:44,800 It's pretty useful. 136 00:09:45,600 --> 00:09:51,600 The thing that makes it not quite so useful is that it only returns, I think, 10 or 15 names at a time. 137 00:09:52,000 --> 00:09:59,100 And as you can imagine, this might return, you know, it's like they're going next, next, next, and there's thousands of these things, right? 138 00:09:59,400 --> 00:10:02,920 So one little spider I wrote is I go out. 139 00:10:02,940 --> 00:10:03,880 And I spider this page. 140 00:10:04,300 --> 00:10:07,900 And I just type in the word that I'm looking for as a subset of a domain name. 141 00:10:08,160 --> 00:10:10,320 And basically it just returns all of them. 142 00:10:10,440 --> 00:10:11,680 It's much, much faster. 143 00:10:13,360 --> 00:10:19,480 Another example or another thing to think about when you want to automate stuff is think about things that you can perform periodically. 144 00:10:20,980 --> 00:10:23,900 I talked a little bit earlier about doing things with PDAs. 145 00:10:24,420 --> 00:10:31,340 Let's say, for example, you work for a corporation that has people in the field all over the country. 146 00:10:31,340 --> 00:10:41,680 You could set it up so that at night, your field representative's computers would go out and download some information from your corporate website. 147 00:10:42,160 --> 00:10:53,980 And then this agent could transform this stuff and put it where it needs to go so that when the salesperson or whoever it is in the morning does a hot sync on their PDA, they've got all that information in their PDA. 148 00:10:54,240 --> 00:10:57,340 So that's an example of something that you would want to perform periodically. 149 00:10:58,200 --> 00:10:59,780 Okay, let's look at some ideas here. 150 00:11:01,940 --> 00:11:05,520 Automatically send an email to your mother every time there's a story about you on CNN. 151 00:11:07,480 --> 00:11:09,080 This may or may not be a good idea. 152 00:11:10,680 --> 00:11:12,320 I guess it depends on your mom. 153 00:11:13,580 --> 00:11:14,500 So what would you do? 154 00:11:14,520 --> 00:11:16,800 You would download pages from CNN. 155 00:11:17,440 --> 00:11:20,020 You would parse, look for stories about you. 156 00:11:20,120 --> 00:11:24,820 And that's really a matter of a simple string comparison, really. 157 00:11:24,940 --> 00:11:26,140 I mean, it's not hard. 158 00:11:27,260 --> 00:11:29,540 Then the action is you would email your mom. 159 00:11:29,880 --> 00:11:31,320 You can either email a woman. 160 00:11:31,340 --> 00:11:32,100 There's a link to the story. 161 00:11:32,440 --> 00:11:34,360 Or you could email the actual story. 162 00:11:37,460 --> 00:11:40,680 Okay, create a service that provides real-time weather data. 163 00:11:41,560 --> 00:11:44,240 In fact, I know several people who are doing this. 164 00:11:44,280 --> 00:11:45,240 This is actually a useful thing. 165 00:11:45,680 --> 00:11:47,820 Download pages from the National Weather Service. 166 00:11:48,560 --> 00:11:50,460 Parse out weather information and forecasts. 167 00:11:50,980 --> 00:11:55,440 And then make this stuff available via some type of either SERP or some other web protocol. 168 00:11:55,760 --> 00:11:58,440 So basically, it's just a service sitting there that people can access. 169 00:12:02,540 --> 00:12:05,980 Track the web technology used by each of the Fortune 500 companies. 170 00:12:06,600 --> 00:12:07,480 Okay, how would you do this? 171 00:12:08,560 --> 00:12:13,940 You would download the HTTP headers from a set of web pages that you have stashed away in a database. 172 00:12:15,360 --> 00:12:16,980 You'd parse out the server information. 173 00:12:18,800 --> 00:12:24,820 And then you would store the stuff in a database and run comparisons and do whatever you want to do with it. 174 00:12:28,400 --> 00:12:29,620 You guys remember the cartoon? 175 00:12:29,620 --> 00:12:31,900 There were two dogs sitting on the street. 176 00:12:32,000 --> 00:12:33,120 One of them said to the other one, 177 00:12:33,260 --> 00:12:35,700 The nice thing about the Internet is no one knows you're a dog. 178 00:12:37,260 --> 00:12:38,340 That's not always the case. 179 00:12:38,420 --> 00:12:40,160 I actually met my dog on the Internet. 180 00:12:41,720 --> 00:12:43,000 There's Jackson right now. 181 00:12:43,060 --> 00:12:45,360 He's showing the proper technique for standing on a 17. 182 00:12:49,380 --> 00:12:52,000 If he knew I was talking about him, he'd kill me. 183 00:12:53,760 --> 00:12:56,040 Anyway, no, I actually met my dog on the Internet. 184 00:12:56,540 --> 00:12:59,600 A lot of animal shelters and rescuers. 185 00:13:00,440 --> 00:13:04,120 We'll have websites where they'll post dogs that are available for adoption. 186 00:13:04,540 --> 00:13:07,360 It's kind of like a canine dating service. 187 00:13:08,720 --> 00:13:10,480 And that's where I met my dog. 188 00:13:11,140 --> 00:13:12,140 It made me think. 189 00:13:12,240 --> 00:13:21,460 If you wanted to, you could periodically run a spider to check when a Jack Russell or any other kind of dog is available at your local shelter. 190 00:13:21,720 --> 00:13:25,940 And again, it's as simple as download, parse, filter, take action. 191 00:13:26,180 --> 00:13:29,600 You download pages from your local animal shelters and dog rescuers. 192 00:13:30,580 --> 00:13:33,340 You'd filter out information about Jack Russell Terriers. 193 00:13:33,660 --> 00:13:36,540 And then you can send yourself an email when a dog is found. 194 00:13:40,200 --> 00:13:40,980 Number five. 195 00:13:42,080 --> 00:13:45,680 Scout all the top employment websites for jobs that match your skills. 196 00:13:45,920 --> 00:13:48,600 And automatically send the contact person a resume. 197 00:13:50,900 --> 00:13:52,060 Good idea? I don't know. 198 00:13:52,120 --> 00:13:52,940 I don't know if I'd do this one. 199 00:13:53,080 --> 00:13:54,640 But it's the kind of thing you can do. 200 00:13:55,040 --> 00:13:56,000 Again, download. 201 00:13:56,220 --> 00:13:57,960 You download pages from employment websites. 202 00:13:58,720 --> 00:13:59,460 Parse and filter. 203 00:13:59,860 --> 00:14:01,200 Jobs that fit your skills. 204 00:14:01,380 --> 00:14:03,460 And gather employee email addresses. 205 00:14:04,240 --> 00:14:07,820 And the action you take is you'd automatically send the resume to appropriate employers. 206 00:14:10,580 --> 00:14:11,320 Number six. 207 00:14:12,920 --> 00:14:17,020 Write a web agent that returns the best price on a dozen roses delivered in Chicago. 208 00:14:17,780 --> 00:14:20,720 This is actually something you could sell if you could do a service like this. 209 00:14:20,800 --> 00:14:23,000 In fact, there are some like this out there. 210 00:14:23,780 --> 00:14:25,900 My Simon, I think, comes to mind. 211 00:14:25,900 --> 00:14:29,960 And I think CNET does something like this for computer hardware. 212 00:14:31,100 --> 00:14:35,000 So what you would do, again, you'd download delivery pages or flower delivery pages. 213 00:14:35,280 --> 00:14:38,300 Check for best prices in Chicago or wherever it is you're looking. 214 00:14:38,720 --> 00:14:41,700 And then you'd print the names of suppliers, offerings, and prices. 215 00:14:41,960 --> 00:14:43,380 Okay, you starting to see some similarity here? 216 00:14:43,820 --> 00:14:47,180 These are vastly different kinds of ideas of things you can do. 217 00:14:47,680 --> 00:14:49,920 The process is very, very similar. 218 00:14:52,100 --> 00:14:53,840 Hide a camera in your medicine cabinet. 219 00:14:54,180 --> 00:14:55,880 When the door opens, take a digital picture. 220 00:14:55,900 --> 00:14:56,940 And post it on a website. 221 00:15:02,060 --> 00:15:03,320 www.medicinecabinet.com 222 00:15:04,600 --> 00:15:06,400 This might also be an idea for a business. 223 00:15:06,560 --> 00:15:06,960 I'm not sure. 224 00:15:08,940 --> 00:15:12,140 So here what you would do basically is you'd have some kind of a trigger mechanism. 225 00:15:12,420 --> 00:15:15,900 I mean, you can interface any kind of hardware you want to an agent, right? 226 00:15:16,600 --> 00:15:18,020 Anything, even a medicine cabinet. 227 00:15:18,800 --> 00:15:20,040 So you can have some kind of a switch. 228 00:15:20,080 --> 00:15:21,760 When the door opens, bam, a picture's taken. 229 00:15:22,180 --> 00:15:23,560 You really don't have to parse anything. 230 00:15:24,300 --> 00:15:25,880 But it's pretty easy to post the stuff. 231 00:15:25,900 --> 00:15:26,820 You can do that stuff on a website then. 232 00:15:30,620 --> 00:15:34,980 Okay, automatically analyze server logs for anomalies and send to a printer when found. 233 00:15:35,720 --> 00:15:41,460 So here instead of going out on the internet, you could conceivably load a local file, 234 00:15:41,640 --> 00:15:43,860 a file on your own network. 235 00:15:44,120 --> 00:15:47,340 I suppose even a log file you find on somebody else's network. 236 00:15:47,960 --> 00:15:51,420 You could parse out anomalies and then you could print out things that don't look right 237 00:15:51,420 --> 00:15:52,400 so you can look at them later. 238 00:15:56,620 --> 00:15:58,500 Create an email-to-fax service. 239 00:15:58,640 --> 00:15:59,780 This is one I actually did. 240 00:16:00,840 --> 00:16:06,840 I started writing spiders and agents back about four years ago when I was working. 241 00:16:06,920 --> 00:16:11,060 I was a consultant over at Medtronic and was involved with a lot of telemedicine kind of stuff. 242 00:16:11,960 --> 00:16:13,740 And this is what I actually did. 243 00:16:13,820 --> 00:16:17,900 I set it up so that if you sent an email to a specific email address, 244 00:16:18,520 --> 00:16:23,340 it would take the contents of the body, 245 00:16:23,340 --> 00:16:27,580 and it would fax it to the number that you put in the subject line. 246 00:16:30,220 --> 00:16:31,160 So how do you do that? 247 00:16:31,460 --> 00:16:36,080 Well, you load, you go out and you get the emails that are sent to a specific address, 248 00:16:37,320 --> 00:16:39,280 you parse the message and the phone number, 249 00:16:39,420 --> 00:16:41,800 and then you fax the message to the phone number. 250 00:16:41,900 --> 00:16:44,260 It's embarrassingly easy. 251 00:16:47,020 --> 00:16:48,220 This idea I love. 252 00:16:48,500 --> 00:16:51,240 Write a new front end to somebody else's online catalog. 253 00:16:51,480 --> 00:16:51,780 Okay. 254 00:16:53,760 --> 00:16:56,740 The idea is not as strange as it sounds. 255 00:16:58,560 --> 00:17:06,480 For example, if you have a client that receives a royalty on things sold on another website, 256 00:17:07,360 --> 00:17:11,340 people might want to make the whole thing look like it's theirs, right? 257 00:17:11,800 --> 00:17:16,340 And if they have a relationship with this other company, they have every right to do that. 258 00:17:16,480 --> 00:17:18,240 So this is not such a far-fetched thing to do. 259 00:17:19,120 --> 00:17:21,560 So here you would somehow gather the contents. 260 00:17:21,780 --> 00:17:26,060 So a form that would normally appear on this other website, 261 00:17:26,860 --> 00:17:29,000 and you'd gather the variables. 262 00:17:29,420 --> 00:17:32,880 They all come from databases or cookies or stuff. 263 00:17:34,600 --> 00:17:39,940 And you make sure that your variables and methods match the form that your target is, 264 00:17:40,140 --> 00:17:43,340 and then you basically submit the stuff to the target site. 265 00:17:46,280 --> 00:17:48,840 This idea I like, but I'm hesitant to do it. 266 00:17:49,400 --> 00:17:51,120 Start a digital clipping service. 267 00:17:51,120 --> 00:17:55,020 A database is information and images about both your client and their competition 268 00:17:55,740 --> 00:18:01,120 by spidering web, FTP, and new servers along with DNS records and new domain name applications. 269 00:18:01,960 --> 00:18:03,820 I'll tell you why I'm not doing this a little bit later. 270 00:18:04,300 --> 00:18:08,740 But basically what you would do is you would download company data from various sources. 271 00:18:10,280 --> 00:18:14,140 You would parse out everything that's applicable about your client or your competitor. 272 00:18:14,520 --> 00:18:19,380 I suppose if you were really smart about this, both the client and the competitor would be your clients, right? 273 00:18:19,380 --> 00:18:21,540 So it would save work. 274 00:18:22,720 --> 00:18:28,440 And then the action you would take is you would somehow post all this stuff on a central database 275 00:18:29,100 --> 00:18:32,400 with a centralized web server so that they could go and access their data. 276 00:18:35,300 --> 00:18:37,100 Okay, those are some ideas, okay? 277 00:18:37,460 --> 00:18:40,060 You see, they all have very similar process. 278 00:18:41,320 --> 00:18:43,500 What they do, though, can be very, very different. 279 00:18:46,240 --> 00:18:48,500 I've written agents in a number of languages. 280 00:18:48,500 --> 00:18:53,760 I first started doing things in Java, again, back when I was doing telemedicine things. 281 00:18:54,100 --> 00:18:58,620 And I was doing it primarily in Java because I wanted to have a graphical user interface. 282 00:18:58,840 --> 00:18:59,840 That was a nice way of doing it. 283 00:19:00,260 --> 00:19:01,800 I did some things in Perl. 284 00:19:01,820 --> 00:19:03,680 Perl is very powerful for this kind of stuff. 285 00:19:04,740 --> 00:19:06,360 I did some stuff in TclTk. 286 00:19:06,620 --> 00:19:07,860 In fact, I actually wrote an article. 287 00:19:09,120 --> 00:19:16,640 It's the March 2000 edition of Web Techniques, 288 00:19:16,740 --> 00:19:18,460 which I think now changed their name to 289 00:19:18,500 --> 00:19:18,920 New Architect. 290 00:19:19,980 --> 00:19:25,700 If you're interested, I'll have a reference to this in all URLs that I'm using at the end of the presentation. 291 00:19:26,660 --> 00:19:30,260 But I did an article about writing intelligent web agents in TclTk. 292 00:19:31,080 --> 00:19:35,760 For about the last two and a half years, I've been writing almost everything in PHP. 293 00:19:37,060 --> 00:19:38,360 I love the language. 294 00:19:40,040 --> 00:19:44,180 I've never had to debug the interpreter, which is a very nice thing. 295 00:19:44,340 --> 00:19:45,400 And it just runs so reliably. 296 00:19:45,400 --> 00:19:54,100 And it's very similar to Perl, but I believe the syntax is much simpler than Perl. 297 00:19:56,500 --> 00:19:59,420 So, if you're going to download files with PHP, how do you do it? 298 00:20:00,060 --> 00:20:06,460 Well, if you're doing a local file, you'd use the method I'm showing you in number one there. 299 00:20:06,700 --> 00:20:10,740 But basically, you just create a file handle to whatever it is you want to access. 300 00:20:11,340 --> 00:20:13,940 If you want to do a web page there in number two, it's the same thing. 301 00:20:14,040 --> 00:20:14,860 You just open a... 302 00:20:15,400 --> 00:20:17,280 A link to a URL. 303 00:20:17,800 --> 00:20:20,160 Then you've got a handle that you use to reference that URL. 304 00:20:21,380 --> 00:20:24,560 PHP also allows you to do FTP if you need to do FTP. 305 00:20:26,080 --> 00:20:26,880 I think... 306 00:20:26,880 --> 00:20:28,840 Did I tell you I wasn't going to show you any code? 307 00:20:29,760 --> 00:20:32,640 My intent was to not show you any code, but here's some code. 308 00:20:33,000 --> 00:20:34,660 Actually, here's a partial listing. 309 00:20:36,000 --> 00:20:38,660 If you're interested in looking at this, I'm not going to walk through it. 310 00:20:38,800 --> 00:20:40,700 This is on the CD-ROM, I believe. 311 00:20:41,520 --> 00:20:44,580 Basically, this is an example of doing socket programming in PHP. 312 00:20:45,400 --> 00:20:52,960 And this particular example goes out and it performs a whois function that looks like this. 313 00:20:54,760 --> 00:20:57,140 I had a client who... 314 00:20:57,140 --> 00:21:01,540 We were talking about some stuff and about doing some stuff like this. 315 00:21:01,740 --> 00:21:11,120 And he told me that the people who run the whois servers, they watch how many hits they get from particular IP addresses. 316 00:21:11,660 --> 00:21:14,360 And they only allow so many in a 24-hour period. 317 00:21:14,360 --> 00:21:15,360 Anybody else hear about this? 318 00:21:15,920 --> 00:21:16,600 They do that? 319 00:21:16,720 --> 00:21:17,360 Do you know what the number is? 320 00:21:19,880 --> 00:21:20,280 Thousands? 321 00:21:22,100 --> 00:21:22,500 Good. 322 00:21:26,740 --> 00:21:28,020 Okay, launching your agent. 323 00:21:29,600 --> 00:21:34,820 I tend to do everything from a command line, even though I write this stuff in PHP. 324 00:21:34,820 --> 00:21:38,700 A lot of people don't write PHP programs this way. 325 00:21:38,820 --> 00:21:41,820 They'll write pro programs that they launch from a command line. 326 00:21:42,040 --> 00:21:43,400 You can also do it from PHP. 327 00:21:44,360 --> 00:21:48,980 If you're going to do it, this gives you some advantages. 328 00:21:49,340 --> 00:21:51,240 For one, you don't need to run a web server. 329 00:21:51,860 --> 00:21:58,120 So like if you're doing stuff in PHP and you're doing it as a module with Apache or something, 330 00:21:58,960 --> 00:22:03,200 I tend to not like doing that because, I don't know, I might be fooling myself, 331 00:22:03,360 --> 00:22:05,760 but I feel safer not having a server on the system. 332 00:22:07,200 --> 00:22:11,020 So there's also a standalone version of PHP that you can see in the first line here. 333 00:22:12,220 --> 00:22:18,080 PHP also has a separate command line version, which you should really use if you're going to do this, 334 00:22:18,200 --> 00:22:25,900 because in addition to not having a lot of the webby kind of stuff that you would normally have, 335 00:22:26,900 --> 00:22:31,280 you can also have separate configuration files and you can do all kinds of cool stuff. 336 00:22:32,180 --> 00:22:34,080 It's also a smaller footprint, I believe. 337 00:22:35,540 --> 00:22:38,480 You can run these things as a scheduled service. 338 00:22:38,680 --> 00:22:40,920 So they can run, like, every hour. 339 00:22:40,920 --> 00:22:42,000 Every six hours. 340 00:22:42,420 --> 00:22:44,280 You can have them run at midnight. 341 00:22:45,260 --> 00:22:48,120 You can have these things run on startup when people log in. 342 00:22:48,760 --> 00:22:53,100 You can run and have them loop continuously, which is a fine thing to do. 343 00:22:53,900 --> 00:22:57,660 In fact, you can have lots of these things running continuously on the same machine, 344 00:22:57,880 --> 00:23:00,860 and you can get some incredible efficiencies by doing that. 345 00:23:01,140 --> 00:23:04,760 Because most of these spiders and web agents, they'll send out a request someplace, 346 00:23:05,260 --> 00:23:07,860 and they spend almost all their time waiting for a reply. 347 00:23:08,220 --> 00:23:10,900 So if you're going to run them simultaneously, 348 00:23:10,920 --> 00:23:14,380 if you have a need to run them simultaneously, it's a worthwhile thing. 349 00:23:16,080 --> 00:23:16,640 Okay. 350 00:23:16,740 --> 00:23:19,480 I showed you how to download stuff using PHP. 351 00:23:20,260 --> 00:23:21,860 I tend not to do that. 352 00:23:22,600 --> 00:23:27,860 What I use instead for downloading stuff is a really great program called Curl. 353 00:23:28,100 --> 00:23:30,320 Okay, see, how many people here are familiar with Curl? 354 00:23:31,480 --> 00:23:32,620 Excellent. Excellent. 355 00:23:33,440 --> 00:23:38,540 Curl is a command line tool for getting and sending files using a URL syntax. 356 00:23:39,180 --> 00:23:39,740 Um. 357 00:23:39,740 --> 00:23:44,700 If you're interested in getting a copy, there's a couple of places where you can get it. 358 00:23:44,840 --> 00:23:47,420 I was thinking about putting it on the CD-ROM, 359 00:23:47,580 --> 00:23:52,080 but they've got binaries you can download for like 50 different platforms, 360 00:23:52,280 --> 00:23:53,660 and I didn't see the need to do that. 361 00:23:54,120 --> 00:23:56,960 Again, these URLs will appear at the end of the presentation, too. 362 00:23:57,900 --> 00:24:00,840 Curl supports a ton of Internet protocols. 363 00:24:02,840 --> 00:24:05,440 And it's open source, but it's not GPL, 364 00:24:05,620 --> 00:24:07,660 which means basically there's no license whatsoever. 365 00:24:08,240 --> 00:24:09,200 My understanding, 366 00:24:09,740 --> 00:24:10,820 and if I'm misspeaking here, 367 00:24:10,920 --> 00:24:11,940 or somebody please raise a hand, 368 00:24:12,140 --> 00:24:14,400 this stuff is completely free software, 369 00:24:14,620 --> 00:24:16,260 so you can do anything you want with it. 370 00:24:18,260 --> 00:24:21,880 Don't confuse Curl with the small URL 371 00:24:21,880 --> 00:24:24,760 with Curl, the client-side programming language, 372 00:24:25,020 --> 00:24:31,240 which is a product that the people at www.curl.com are selling. 373 00:24:32,700 --> 00:24:36,440 There's also a copy of the Curl manual on the CD-ROM. 374 00:24:36,680 --> 00:24:38,900 So if you're interested in looking at all the features, 375 00:24:38,900 --> 00:24:40,240 it's got tons of features. 376 00:24:40,540 --> 00:24:42,560 I'm going to just show you a few of them here. 377 00:24:44,040 --> 00:24:46,600 To use Curl, you just type Curl, 378 00:24:46,600 --> 00:24:47,960 and then your target, 379 00:24:48,180 --> 00:24:50,380 and it'll take everything it receives 380 00:24:50,900 --> 00:24:52,920 and direct it to your standard output device, 381 00:24:53,120 --> 00:24:55,660 which in most cases is going to be your screen. 382 00:24:56,240 --> 00:24:58,920 You can also redirect the contents to a file. 383 00:25:00,320 --> 00:25:02,600 You can also use the number 3 there. 384 00:25:02,700 --> 00:25:03,720 You can use the O switch, 385 00:25:04,340 --> 00:25:06,780 so you can set the output to a specific file. 386 00:25:07,440 --> 00:25:12,820 The way I tend to use Curl is I use it inside of PHP, 387 00:25:13,540 --> 00:25:14,880 where I will do things, 388 00:25:14,960 --> 00:25:16,260 I'll actually run like a little shell 389 00:25:17,660 --> 00:25:21,480 to execute Curl within PHP. 390 00:25:21,700 --> 00:25:22,680 And the nice thing here, if you look, 391 00:25:22,960 --> 00:25:27,640 it'll take the entire contents of the default HTML page 392 00:25:28,340 --> 00:25:30,040 from this fictitious website 393 00:25:30,600 --> 00:25:32,300 and load it all into this variable, 394 00:25:32,500 --> 00:25:34,240 so I don't even have to create a file or anything. 395 00:25:34,360 --> 00:25:35,520 It's just all in that variable. 396 00:25:35,520 --> 00:25:37,220 So once it's in that variable, 397 00:25:37,500 --> 00:25:41,260 it's very convenient and very easy to parse out. 398 00:25:41,840 --> 00:25:46,000 If you're just writing PHP for a web application or something, 399 00:25:46,580 --> 00:25:47,720 never do this. 400 00:25:47,920 --> 00:25:51,580 Don't run command line stuff inside your web applications. 401 00:25:52,620 --> 00:25:54,280 Again, maybe I'm fooling myself. 402 00:25:54,420 --> 00:25:56,360 I'm feeling safe in doing this 403 00:25:56,360 --> 00:25:58,740 because there's no server attached to it. 404 00:26:00,940 --> 00:26:03,740 Here's an example of one of the options you can have with Curl. 405 00:26:05,520 --> 00:26:07,200 In this example, I'm downloading the headers 406 00:26:07,200 --> 00:26:09,180 for the New York Times website, 407 00:26:09,860 --> 00:26:11,360 and there's all kinds of cool stuff. 408 00:26:11,460 --> 00:26:12,680 You can see what kind of server they're using. 409 00:26:13,140 --> 00:26:16,760 So if you're thinking back to the one idea 410 00:26:16,760 --> 00:26:20,380 where you monitor the Internet technology 411 00:26:20,380 --> 00:26:22,880 that's used by the top companies, 412 00:26:23,500 --> 00:26:25,300 this is basically how you would do it. 413 00:26:25,820 --> 00:26:28,180 You can also see there's a cookie that's being set. 414 00:26:29,860 --> 00:26:32,780 Curl also allows you to send cookies back to servers, 415 00:26:32,900 --> 00:26:33,620 which is very nice. 416 00:26:35,920 --> 00:26:37,660 This was an HTML page, 417 00:26:38,400 --> 00:26:41,320 but you can download anything with Curl. 418 00:26:41,440 --> 00:26:42,560 It doesn't have to be HTML. 419 00:26:42,680 --> 00:26:44,460 It can be images or Flash or what have you. 420 00:26:46,020 --> 00:26:48,980 It's got some nice ways of dealing with password-protected sites. 421 00:26:49,160 --> 00:26:51,020 You basically just set up your URL, 422 00:26:51,300 --> 00:26:53,280 you set up your user and password, 423 00:26:53,540 --> 00:26:56,640 and then you use the U switch in Curl 424 00:26:56,640 --> 00:26:59,840 to pass the username and password 425 00:26:59,840 --> 00:27:03,200 to whichever site you're using 426 00:27:03,200 --> 00:27:05,000 that uses standard authentication. 427 00:27:08,220 --> 00:27:10,640 The other thing that it's got that's really slick 428 00:27:10,640 --> 00:27:13,040 is it allows you to download sites that are encrypted, 429 00:27:13,720 --> 00:27:16,080 and all you have to do to do that 430 00:27:17,400 --> 00:27:21,200 is add an S to your protocol right here, 431 00:27:21,260 --> 00:27:25,580 and then it automatically decrypts it, 432 00:27:26,180 --> 00:27:29,120 and it will throw everything to this variable called page data, 433 00:27:29,260 --> 00:27:30,620 which is pretty slick. 434 00:27:33,440 --> 00:27:34,540 Something you need to remember 435 00:27:34,540 --> 00:27:35,320 when you're writing, 436 00:27:35,520 --> 00:27:35,720 when you're sending agents, 437 00:27:36,900 --> 00:27:38,560 and you're going out to servers, 438 00:27:39,760 --> 00:27:43,320 you're going to leave a log in their log file 439 00:27:43,320 --> 00:27:45,200 that shows that somebody's been there. 440 00:27:45,820 --> 00:27:47,640 And if you don't do anything with Curl, 441 00:27:47,700 --> 00:27:50,220 I think basically it just says Curl and the version number, 442 00:27:51,220 --> 00:27:53,080 but you can make it look like anything you want. 443 00:27:53,920 --> 00:27:54,880 For example... 444 00:28:11,500 --> 00:28:13,600 You can also send an email to Curl 445 00:28:13,600 --> 00:28:15,120 and it will send you a nice log 446 00:28:15,120 --> 00:28:16,640 and then it will send you an email 447 00:28:17,640 --> 00:28:20,200 that says, well, I'm in this situation, 448 00:28:20,500 --> 00:28:22,200 and it's saying, well, there's this thing 449 00:28:22,200 --> 00:28:24,460 that we can't do anything about 450 00:28:24,460 --> 00:28:27,540 or that we can't do anything about, 451 00:28:27,540 --> 00:28:29,460 and then it sends you an email 452 00:28:29,460 --> 00:28:31,660 and it will always send you an email 453 00:28:31,660 --> 00:28:32,820 and it will send you an email 454 00:28:32,820 --> 00:28:34,340 and it will send you an email 455 00:28:34,340 --> 00:28:35,620 that says I'm in a situation 456 00:28:35,620 --> 00:28:40,400 and SUBSCRIBE to my blog 457 00:28:40,400 --> 00:28:41,980 or something like that. 458 00:28:47,080 --> 00:28:50,380 And then it will tell you 459 00:28:50,380 --> 00:28:51,660 and send you an email 460 00:28:51,660 --> 00:28:54,180 and it will send you an email 461 00:28:54,180 --> 00:28:54,840 that next to it 462 00:28:54,840 --> 00:28:56,000 that tells you, 463 00:28:56,360 --> 00:28:56,400 what the heck 464 00:28:56,400 --> 00:28:56,680 you were doing 465 00:28:56,680 --> 00:28:57,460 and you've been there 466 00:28:57,460 --> 00:28:59,040 that says what acontecer 467 00:28:59,040 --> 00:29:00,420 and it's 468 00:29:00,420 --> 00:29:00,600 you know, 469 00:29:02,820 --> 00:29:04,320 when you go out 470 00:29:07,540 --> 00:29:09,200 Okay, I'm going to talk about person. 471 00:29:12,520 --> 00:29:14,520 I think that's a person. 472 00:29:15,020 --> 00:29:15,480 I think that's a person. 473 00:29:15,500 --> 00:29:17,260 I think that's a person. 474 00:29:17,260 --> 00:29:20,460 I think that's a person. 475 00:29:20,460 --> 00:29:21,000 I think that's a person. 476 00:29:22,480 --> 00:29:24,780 I think that's a person. 477 00:29:25,720 --> 00:29:26,360 I think that's a person. 478 00:29:26,580 --> 00:29:28,360 I think that's a person. 479 00:29:29,340 --> 00:29:30,260 I think that's a person. 480 00:29:30,860 --> 00:29:32,420 I think that's a person. 481 00:29:50,800 --> 00:29:52,160 open the source code 482 00:29:52,160 --> 00:29:55,620 and then we'll take the source code and it'll come up here 483 00:30:02,120 --> 00:30:03,480 slash t 484 00:30:03,480 --> 00:30:10,640 and then we'll do a call and we'll go back down 485 00:30:10,640 --> 00:30:14,360 down a list of the address you want to pin 486 00:30:14,360 --> 00:30:19,360 and then we'll call our address 487 00:30:56,700 --> 00:31:00,960 Now, this will help, but makes it difficult to understand. 488 00:31:03,460 --> 00:31:07,260 Basically, you have to find what you're looking for. 489 00:31:07,860 --> 00:31:12,200 And you can find it by some sort of written code or something. 490 00:31:15,220 --> 00:31:19,040 So, you can find it by some sort of written code or something. 491 00:31:22,320 --> 00:31:26,720 By the way, when you use it, it will make your mind switch to a different direction. 492 00:31:28,180 --> 00:31:30,620 And the answer is, it will help you. 493 00:31:32,200 --> 00:31:34,060 It's a little bit like a little star. 494 00:31:34,240 --> 00:31:36,140 It's a little bit like a little star. 495 00:31:36,180 --> 00:31:37,220 It's a little bit like a little star. 496 00:31:37,880 --> 00:31:39,700 It's a little bit like a little star. 497 00:31:40,860 --> 00:31:42,180 It's a little bit like a little star. 498 00:31:43,920 --> 00:31:46,180 It's a little bit like a little star. 499 00:31:47,260 --> 00:31:49,160 It's a little bit like a little star. 500 00:31:49,660 --> 00:31:50,120 It's a little bit like a little star. 501 00:31:51,960 --> 00:31:53,800 It's a little bit like a little star. 502 00:31:53,800 --> 00:31:55,540 It's a little bit like a little star. 503 00:31:55,540 --> 00:31:56,660 It's a little bit like a little star. 504 00:31:56,900 --> 00:31:58,380 It's a little bit like a little star. 505 00:31:58,380 --> 00:31:59,200 It's a little bit like a little star. 506 00:32:00,420 --> 00:32:01,880 It's a little bit like a little star. 507 00:32:02,500 --> 00:32:04,900 It's a little bit like a little star. 508 00:32:04,900 --> 00:32:08,760 It's a little bit like a little star. 509 00:32:08,840 --> 00:32:09,460 It's a little bit like a little star. 510 00:32:10,420 --> 00:32:11,500 It's a little bit like a little star. 511 00:32:11,700 --> 00:32:12,180 It's a little bit like a little star. 512 00:32:12,180 --> 00:32:16,540 Recently, as I said, it's a great time for a job interview. 513 00:32:17,540 --> 00:32:19,420 I'll get to that a little bit later. 514 00:32:20,120 --> 00:32:21,400 I think it's nice. 515 00:32:21,780 --> 00:32:24,560 And that's the most important thing. 516 00:32:25,180 --> 00:32:25,700 Target. 517 00:32:27,080 --> 00:32:27,600 Jobs. 518 00:32:30,500 --> 00:32:33,120 There's a lot of stuff that isn't much of an interview, generally. 519 00:32:34,200 --> 00:32:36,940 But I'm going to throw out the stuff. 520 00:32:36,940 --> 00:32:37,020 I don't know. 521 00:32:37,160 --> 00:32:38,560 . 522 00:32:38,560 --> 00:32:38,760 . 523 00:32:40,820 --> 00:32:42,220 . 524 00:32:42,220 --> 00:32:43,940 . 525 00:32:43,940 --> 00:32:44,060 . 526 00:33:47,080 --> 00:33:49,880 Thank you. 527 00:34:12,000 --> 00:34:13,700 Thank you. 528 00:34:45,560 --> 00:34:48,360 Thank you. 529 00:35:20,700 --> 00:35:22,120 Thank you.