From gslindstrom at gmail.com Tue Dec 11 20:15:29 2007 From: gslindstrom at gmail.com (Greg Lindstrom) Date: Tue, 11 Dec 2007 13:15:29 -0600 Subject: [PyAR2] And a comic Message-ID: This has been going around the Python community for the last week or so. There is even talk about putting it on the official PyCon tee shirts! --greg http://xkcd.com/224/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/mailman/private/pyar2/attachments/20071211/b37bbb25/attachment.htm From gslindstrom at gmail.com Tue Dec 11 20:12:22 2007 From: gslindstrom at gmail.com (Greg Lindstrom) Date: Tue, 11 Dec 2007 13:12:22 -0600 Subject: [PyAR2] O'Reilly User Group News Message-ID: O'Reilly News for User Group Members December 11, 2007 New Releases: Books, Short Cuts, and Rough Cuts [image: The Creative Digital Darkroom]Get 35% off from O'Reilly, No Starch, Paraglyph, PC Publishing, Pragmatic Bookshelf, Rocky Nook, SitePoint, or YoungJin books you purchase directly from O'Reilly.* Just use code "DSUG"* when ordering onlineor by phone 800-998-9938. *Free ground shipping* on orders of $29.95 or more. See details . Did you know you can request a free book or PDF to review for your group? Ask your group leader for more information. For book review writing tips and suggestions, go to: http://ug.oreilly.com/bookreviews.html New Releases: Books, Short Cuts, and Rough Cuts: - Visualizing Data: Rough Cuts Version - Adobe InDesign CS3 One-on-One - Advanced Rails - Advanced Rails Recipes ( *Pragmatic Bookshelf*) - Apache Cookbook, Second Edition - The Book of PF (*No Starch*) - C# 3.0 Cookbook, Third Edition - C# 3.0 Design Patterns - The Creative Digital Darkroom - Digital Astrophotography (*Rocky Nook*) - Groovy Recipes (*Pragmatic Bookshelf*) - Hacking: The Art of Exploitation, Second Edition (*No Starch*) - Head First JavaScript - Head First Software Development - iPhone UK: The Missing Manual - Mac OS X Leopard: The Missing Manual - MAKE: Technology on Your Time Volume 12 - Photoshop CS3 RAW - Programming C# 3.0, Fifth Edition - Prototype and script.aculo.us (*Pragmatic Bookshelf*) - Sound Mixing Tips and Tricks (*PC Publishing*) - Take Your Photography to the Next Level (*Rocky Nook*) - Windows Vista Annoyances - X Power Tools MAKE Magazine Subscriptions [image: makezine.com] The annual subscription price for four issues is $34.95. When you subscribe with this link, you'll get a free issue--one plus four more for $34.95. So subscribe for yourself or friends with this great offer for UG Members: five volumes for the cost of four. Subscribe at: http://www.makezine.com/go/ugsub Craft Magazine Subscriptions [image: craftzine.com] The annual subscription price for four issues is $34.95. When you subscribe with this link, you'll get a free issue--one plus four more for $34.95. So subscribe for yourself or friends with this great offer for charter subscribers: five volumes for the cost of four. Subscribe at: http://www.craftzine.com/go/craftug ------------------------------ Upcoming Events -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/mailman/private/pyar2/attachments/20071211/99e818a3/attachment.htm From gslindstrom at gmail.com Tue Dec 11 20:17:04 2007 From: gslindstrom at gmail.com (Greg Lindstrom) Date: Tue, 11 Dec 2007 13:17:04 -0600 Subject: [PyAR2] Correct Comic Message-ID: Here is the comic. Sorry about that... http://www.xkcd.com/353/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/mailman/private/pyar2/attachments/20071211/5aa70a4c/attachment.htm From srilyk at gmail.com Tue Dec 11 21:22:43 2007 From: srilyk at gmail.com (W W) Date: Tue, 11 Dec 2007 14:22:43 -0600 Subject: [PyAR2] Correct Comic In-Reply-To: References: Message-ID: <333efb450712111222u730ced1cx3a77f2ccf6753fe4@mail.gmail.com> I actually saw that a few days ago - xkcd is one of my faves. And that was a great one, I actually lol'ed! On Dec 11, 2007 1:17 PM, Greg Lindstrom wrote: > Here is the comic. Sorry about that... > > http://www.xkcd.com/353/ > > _______________________________________________ > PyAR2 mailing list > PyAR2 at python.org > http://mail.python.org/mailman/listinfo/pyar2 > > -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn't. - Primo Levi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/mailman/private/pyar2/attachments/20071211/0e946801/attachment.htm From srilyk at gmail.com Thu Dec 20 20:06:43 2007 From: srilyk at gmail.com (W W) Date: Thu, 20 Dec 2007 13:06:43 -0600 Subject: [PyAR2] Accessing Web Data Message-ID: <333efb450712201106t2923658er9a6e30afc0b2591a@mail.gmail.com> Hi, I'm a bit of a beginner at python, and I'm trying to figure out how to use python to retrieve webpages, and so far I'm unsuccessful in my attempts to find any information online. Basically what I'm wanting to do is write a program to search google/yahoo/etc. and return the site content so I can then search it. I'm sure (at least on linux) I could send a system command to wget the file, but that would severely limit cross-platform use, and worse I'm sure it's not very secure. Any pointers on how to do it or where to find the information would be appreciated, thanks! -Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn't. - Primo Levi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/mailman/private/pyar2/attachments/20071220/1a8db1e4/attachment.htm From bob.fahr at gmail.com Thu Dec 20 20:42:25 2007 From: bob.fahr at gmail.com (Bob Fahr) Date: Thu, 20 Dec 2007 13:42:25 -0600 Subject: [PyAR2] Accessing Web Data In-Reply-To: <333efb450712201106t2923658er9a6e30afc0b2591a@mail.gmail.com> References: <333efb450712201106t2923658er9a6e30afc0b2591a@mail.gmail.com> Message-ID: <3e011c0f0712201142id042fbfx7d6324fc726d33d7@mail.gmail.com> Wayne, One approach is to use the urllib library to fetch a page and then use regular expressions to find the particular item you want on the page. Here is an example of getting a stock quote from google, the stock symbol is passed in as the argument: import urllib import re def get_quote(symbol): base_url = 'http://finance.google.com/finance?q=' content = urllib.urlopen(base_url + symbol).read() m = re.search('class="pr".*?>(.*?)<', content) if m: quote = m.group(1) else: quote = 'no quote available for: ' + symbol return quote The regular expressions can get fairly complex depending on what information you are trying to find. Another approach is to use the httplib.HTTPConnection and HTMLParser libraries. You use HTTPConnection to create a connection to the website, and then use the connection methods to fetch date and HTTP status and other info. Once you have the data you can use the parser to parse the HTML tags. You'll have to overload methods like handle_starttag and then the overloaded methods get called during parsing. I use handle_startag to evaluate each start tag in the HTML and find all of the address tags (links). Here's a real short example: import httplib from HTMLParser import HTMLParser class MyHTMLParser(HTMLParser): def __init__(self): self.links = []; HTMLParser.__init__(self) def handle_starttag(self, tag, attributes): if tag == 'a': name, link = attributes[0] if link.endswith('.html'): self.links.append(link) # in main parser = MyHTMLParser() connection = httplib.HTTPConnection('www.google.com') connection.request('GET', '/some_search_url') response = connection.getresponse() data_length = response.getheader('content-length') data = response.read() parser.feed(data) for link in parser.links: do something Hope this gets you started. On Dec 20, 2007 1:06 PM, W W wrote: > Hi, > > I'm a bit of a beginner at python, and I'm trying to figure out how to use > python to retrieve webpages, and so far I'm unsuccessful in my attempts to > find any information online. > > Basically what I'm wanting to do is write a program > to search google/yahoo/etc. and return the site content so I can then search it. > > > I'm sure (at least on linux) I could send a system command to wget the > file, but that would severely limit cross-platform use, and worse I'm sure > it's not very secure. > > Any pointers on how to do it or where to find the information would be > appreciated, thanks! > -Wayne > > -- > To be considered stupid and to be told so is more painful than being > called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every > weakness, every vice, has found its defenders, its rhetoric, its ennoblement > and exaltation, but stupidity hasn't. - Primo Levi > _______________________________________________ > PyAR2 mailing list > PyAR2 at python.org > http://mail.python.org/mailman/listinfo/pyar2 > > -- Bob Fahr bob.fahr at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/mailman/private/pyar2/attachments/20071220/42ddc3ef/attachment.htm From Chad_Cooper at SWN.COM Thu Dec 20 21:03:28 2007 From: Chad_Cooper at SWN.COM (Chad Cooper) Date: Thu, 20 Dec 2007 14:03:28 -0600 Subject: [PyAR2] Accessing Web Data In-Reply-To: <333efb450712201106t2923658er9a6e30afc0b2591a@mail.gmail.com> References: <333efb450712201106t2923658er9a6e30afc0b2591a@mail.gmail.com> Message-ID: Beautiful Soup might help you out, but I think its geared more for screen-scraping... http://www.crummy.com/software/BeautifulSoup/ chad! ________________________________ From: pyar2-bounces at python.org [mailto:pyar2-bounces at python.org] On Behalf Of W W Sent: Thursday, December 20, 2007 1:07 PM To: pyar2 at python.org Subject: [PyAR2] Accessing Web Data Hi, I'm a bit of a beginner at python, and I'm trying to figure out how to use python to retrieve webpages, and so far I'm unsuccessful in my attempts to find any information online. Basically what I'm wanting to do is write a program to search google/yahoo/etc. and return the site content so I can then search it. I'm sure (at least on linux) I could send a system command to wget the file, but that would severely limit cross-platform use, and worse I'm sure it's not very secure. Any pointers on how to do it or where to find the information would be appreciated, thanks! -Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn't. - Primo Levi Notice: This e-mail may contain privileged and/or confidential information and is intended only for the addressee. If you are not the addressee or the person responsible for delivering it to the addressee, you may not copy or distribute this communication to anyone else. If you received this communication in error, please notify us immediately by telephone or return e-mail and promptly delete the original message from your system. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/mailman/private/pyar2/attachments/20071220/7c9054db/attachment.htm From pyar2 at cowsgomoo.org Thu Dec 20 23:06:16 2007 From: pyar2 at cowsgomoo.org (Coltrey Mather) Date: Thu, 20 Dec 2007 16:06:16 -0600 Subject: [PyAR2] Accessing Web Data In-Reply-To: <3e011c0f0712201142id042fbfx7d6324fc726d33d7@mail.gmail.com> References: <333efb450712201106t2923658er9a6e30afc0b2591a@mail.gmail.com> <3e011c0f0712201142id042fbfx7d6324fc726d33d7@mail.gmail.com> Message-ID: urllib.urlopen() is one of those things that works, but isn't, by default, nice to server admins. dive into python has a brief example using urlopen() to fetch stuff, as well as a piece on processing html. http://diveintopython.org/html_processing/index.html diveintopython seems to be targeted, generally speaking, to people with some sort of background .. so you may have to warp your mind around it for a few minutes before you get it. On Dec 20, 2007 1:42 PM, Bob Fahr wrote: > Wayne, > One approach is to use the urllib library to fetch a page and then use > regular expressions to find the particular item you want on the page. Here > is an example of getting a stock quote from google, the stock symbol is > passed in as the argument: > > import urllib > import re > > def get_quote(symbol): > base_url = 'http://finance.google.com/finance?q=' > content = urllib.urlopen(base_url + symbol).read() > m = re.search('class="pr".*?>(.*?)<', content) > if m: > quote = m.group(1) > else: > quote = 'no quote available for: ' + symbol > return quote > > The regular expressions can get fairly complex depending on what > information you are trying to find. > > Another approach is to use the httplib.HTTPConnection and HTMLParser > libraries. You use HTTPConnection to create a connection to the website, > and then use the connection methods to fetch date and HTTP status and other > info. Once you have the data you can use the parser to parse the HTML > tags. You'll have to overload methods like handle_starttag and then the > overloaded methods get called during parsing. I use handle_startag to > evaluate each start tag in the HTML and find all of the address tags > (links). Here's a real short example: > > import httplib > from HTMLParser import HTMLParser > > class MyHTMLParser(HTMLParser): > def __init__(self): > self.links = []; > HTMLParser.__init__(self) > def handle_starttag(self, tag, attributes): > if tag == 'a': > name, link = attributes[0] > if link.endswith('.html'): > self.links.append(link) > > # in main > parser = MyHTMLParser() > connection = httplib.HTTPConnection ('www.google.com') > connection.request('GET', '/some_search_url') > response = connection.getresponse() > data_length = response.getheader('content-length') > data = response.read() > parser.feed(data) > > for link in parser.links: > do something > > Hope this gets you started. > > On Dec 20, 2007 1:06 PM, W W < srilyk at gmail.com> wrote: > > > Hi, > > > > I'm a bit of a beginner at python, and I'm trying to figure out how to > > use python to retrieve webpages, and so far I'm unsuccessful in my attempts > > to find any information online. > > > > Basically what I'm wanting to do is write a program > > to search google/yahoo/etc. and return the site content so I can then search it. > > > > > > I'm sure (at least on linux) I could send a system command to wget the > > file, but that would severely limit cross-platform use, and worse I'm sure > > it's not very secure. > > > > Any pointers on how to do it or where to find the information would be > > appreciated, thanks! > > -Wayne > > > > -- > > To be considered stupid and to be told so is more painful than being > > called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every > > weakness, every vice, has found its defenders, its rhetoric, its ennoblement > > and exaltation, but stupidity hasn't. - Primo Levi > > _______________________________________________ > > PyAR2 mailing list > > PyAR2 at python.org > > http://mail.python.org/mailman/listinfo/pyar2 > > > > > > > -- > Bob Fahr > bob.fahr at gmail.com > _______________________________________________ > PyAR2 mailing list > PyAR2 at python.org > http://mail.python.org/mailman/listinfo/pyar2 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/mailman/private/pyar2/attachments/20071220/d7fc43fe/attachment-0001.htm From srilyk at gmail.com Fri Dec 21 13:31:17 2007 From: srilyk at gmail.com (W W) Date: Fri, 21 Dec 2007 06:31:17 -0600 Subject: [PyAR2] Thanks and another question... Message-ID: <333efb450712210431h3af9b0c8jae89f0325338d7df@mail.gmail.com> The urllib info was very helpful! This isn't a specific question, more of one in general - I don't really understand what's going on. I've seen it in python, but I'm working my way through the PyGTK+ tutorial and I just came across these two lines: def callback(self, widget, data=None): print "Hello again - %s was pressed" % data and I'm wondering exactly what the %s and % data mean? I've seen it several places but never really an explanation of what it is or how it does what it does? Thanks! Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn't. - Primo Levi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/mailman/private/pyar2/attachments/20071221/4b3233e5/attachment.htm From pyar2 at cowsgomoo.org Fri Dec 21 13:52:42 2007 From: pyar2 at cowsgomoo.org (Coltrey Mather) Date: Fri, 21 Dec 2007 06:52:42 -0600 Subject: [PyAR2] Thanks and another question... In-Reply-To: <333efb450712210431h3af9b0c8jae89f0325338d7df@mail.gmail.com> References: <333efb450712210431h3af9b0c8jae89f0325338d7df@mail.gmail.com> Message-ID: http://docs.python.org/lib/typesseq-strings.html On Dec 21, 2007 6:31 AM, W W wrote: > The urllib info was very helpful! > > This isn't a specific question, more of one in general - I don't really > understand what's going on. > I've seen it in python, but I'm working my way through the PyGTK+ tutorial > and I just came across these two lines: > > def callback(self, widget, data=None): > print "Hello again - %s was pressed" % data > > and I'm wondering exactly what the %s and % data mean? I've seen it > several places but never really an explanation of what it is or how it does > what it does? > > Thanks! > Wayne > > -- > To be considered stupid and to be told so is more painful than being > called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every > weakness, every vice, has found its defenders, its rhetoric, its ennoblement > and exaltation, but stupidity hasn't. - Primo Levi > _______________________________________________ > PyAR2 mailing list > PyAR2 at python.org > http://mail.python.org/mailman/listinfo/pyar2 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/mailman/private/pyar2/attachments/20071221/20af5b69/attachment.htm From srilyk at gmail.com Fri Dec 21 15:23:26 2007 From: srilyk at gmail.com (W W) Date: Fri, 21 Dec 2007 08:23:26 -0600 Subject: [PyAR2] Thanks and another question... In-Reply-To: References: <333efb450712210431h3af9b0c8jae89f0325338d7df@mail.gmail.com> Message-ID: <333efb450712210623k4c25013dp8a62c0d9ad6c34a1@mail.gmail.com> Ah! Those examples were super helpful! Thanks! On Dec 21, 2007 6:55 AM, Greg Lindstrom wrote: > Here are some examples: > > w = 'World' > print 'Hello, %s' % World ==> 'Hello, World' > > c = 2 > print 'Count = %d now' % c ==> 'Count = 2 now' > > count = 3 > print 'Hello, %s. Count = %d' % (w, count) ==> 'Hello, World. Count = > 3' > > Notice that since I am putting 2 values in the thirs example, I have to > "wrap" the values in ()'s. > > HTH > --greg > > On Dec 21, 2007 6:31 AM, W W < srilyk at gmail.com> wrote: > > > The urllib info was very helpful! > > > > This isn't a specific question, more of one in general - I don't really > > understand what's going on. > > I've seen it in python, but I'm working my way through the PyGTK+ > > tutorial and I just came across these two lines: > > > > def callback(self, widget, data=None): > > print "Hello again - %s was pressed" % data > > > > and I'm wondering exactly what the %s and % data mean? I've seen it > > several places but never really an explanation of what it is or how it does > > what it does? > > > > Thanks! > > Wayne > > > > -- > > To be considered stupid and to be told so is more painful than being > > called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every > > weakness, every vice, has found its defenders, its rhetoric, its ennoblement > > and exaltation, but stupidity hasn't. - Primo Levi > > _______________________________________________ > > PyAR2 mailing list > > PyAR2 at python.org > > http://mail.python.org/mailman/listinfo/pyar2 > > > > > -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn't. - Primo Levi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/mailman/private/pyar2/attachments/20071221/74d78e64/attachment.htm From gslindstrom at gmail.com Fri Dec 21 18:19:30 2007 From: gslindstrom at gmail.com (Greg Lindstrom) Date: Fri, 21 Dec 2007 11:19:30 -0600 Subject: [PyAR2] Thanks and another question... In-Reply-To: <333efb450712210623k4c25013dp8a62c0d9ad6c34a1@mail.gmail.com> References: <333efb450712210431h3af9b0c8jae89f0325338d7df@mail.gmail.com> <333efb450712210623k4c25013dp8a62c0d9ad6c34a1@mail.gmail.com> Message-ID: On Dec 21, 2007 8:23 AM, W W wrote: > Ah! Those examples were super helpful! Thanks! Thanks. The formatters support everything one can do in "C". Some more examples: Minimum length of a string field (notice the '25' between the '%' and 's'). >>>t = 'this is a test' >>> print '-->[%25s]<--' % w -->[ this is a test]<-- Use a ''-' to left justify: >>> print '-->[%-25s]<--' % w -->[this is a test ]<-- You can specify the maximum length of a string field, too (notice the value '.5'): >>> print '-->[%.5s]<--' % w -->[this ]<-- Combine the above two to force the string to be a certain length (in this case 20 bytes): >>> print '-->[%20.20s]<--' % w -->[ this is a test]<-- You can do the same with integers, let's force a column to be 8-bytes wide using the '%d' identifier n = 123 >>> print '-->[%8d]<--' % n -->[ 123]<-- And if you want leading zeros... >>> print '-->[%08d]<--' % n -->[00000123]<-- Floats allow you to specify a maximum with (before the decimal point) and precision (after the decimal point). Use the %f format identifier. f = 1234.56789 >>> print f 1234.56789 >>> print '-->[%6.2f]<--' % f -->[1234.57]<-- notice it has been rounded. Once you get the hang of it, you can look in the reference guide for a mind-numbing list of format identifiers and qualifiers. I believe python 3000 will change the print statement to a function and use a different formatting style along the lines of: >>> planet = 'World' >>> name = 'Greg' >>> print('Hello, {1}. My name is {2}' % (planet, name)) Hello, World. My name is Greg. I'll try to find out more at PyCon in March. --greg -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/mailman/private/pyar2/attachments/20071221/4d094aab/attachment.htm From gslindstrom at gmail.com Fri Dec 28 23:36:18 2007 From: gslindstrom at gmail.com (Greg Lindstrom) Date: Fri, 28 Dec 2007 16:36:18 -0600 Subject: [PyAR2] Let's Meet Message-ID: I'd like for as many of us as possible to meet and discuss what we want this group to be/do. My push will be for a more traditional user group meeting with presentations, questions/answers and maybe even time for people to bring in their current projects for help with how to design/build them. Others have mentioned getting a group project to work on, which I think would be a great thing to do as well. I'm sure there are other ideas out there just waiting to be brought up. Keeping in mind that March is PyCon in Chicago (you really should consider going), I never got around to plotting the zip codes -- sorry -- but may I suggest we meet sometime in January in Conway? If there are a number of people up North (so to speak), perhaps we could schedule a meeting in February up in Fayetteville (I'd be happy to drive up to meet with you). The CARLUG group meets at the San Fransisco Bread Company in Conway, which would be a good place to talk. If we decide to meet up North, could someone suggest a place? Or, if more people in Little Rock want to meet, we could meet "down South" :-P If there's interest to meet in Conway, I'll propose the 12th or 26th (I'm out of town on the 19th). February I would be available in the 16th only (sorry, this is right in the middle of gymnastics season and my daughter is competing level 5 this year). For those of you wanting to do a project, what do you have in mind? I'd love to help out, but we're going to need someone to step up and lead on this. Happy New Year, everyone! --greg -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/mailman/private/pyar2/attachments/20071228/6a8fb2c9/attachment.htm