@@ -0,0 +1,1203 @@
+# need to 'pip install grequests'%0Aimport grequests%0Afrom html.parser import HTMLParser%0A%0Aclass FetchTitleTag(HTMLParser):%0A    def __init__(self):%0A        HTMLParser.__init__(self)%0A        self.inTitle = False%0A    def handle_starttag(self, tag, attrs):%0A        if tag == 'title':%0A            self.inTitle = True%0A    def handle_endtag(self, tag):%0A        if tag == 'title':%0A            self.inTitle = False%0A    def handle_data(self, data):%0A        if self.inTitle:%0A            print('title: %22%25s%22' %25 data.strip())%0A%0Aurls = %5B%0A    'http://google.com',%0A    'http://github.com'%0A%5D%0A%0A# version using grequests (https://github.com/kennethreitz/grequests)%0A# same api as requests, mostly (http://docs.python-requests.org/en/master/)%0Arequests_unsent = (grequests.get(u) for u in urls)%0A# like map, but returns generator%0Arequests_iterable = grequests.imap(requests_unsent)%0A%0Aparser = FetchTitleTag()%0A%0Afor response in requests_iterable:%0A    parser.feed(response.text)%0A    # prints text of the response (just an html page)%0A    # print(response.text)%0A    # prints the status code of the response (should be 200)%0A    print(response.status_code)%0A%0A# can also potentially do this with asyncio/aiohttp, but more annoying to set up%0A

add python async webpage fetch example