Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:text': 0.05; 'modified': 0.07; 'none:': 0.07; 'expected.': 0.09; 'skip:/ 10': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'guessing': 0.16; 'pdb': 0.16; 'cc:addr:python.org': 0.22; 'string,': 0.24; 'cc:2**0': 0.24; 'script': 0.25; 'header:In- Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'yields': 0.31; 'running': 0.33; 'received:google.com': 0.35; 'subject:?': 0.36; 'skip:- 20': 0.37; 'new': 0.61; 'as:': 0.81; 'to:addr:yahoo.com': 0.81 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=2ytHbaeQqLqX7DKQfx2N3kL0d8SUsPKn6BUY/x0WZ0E=; b=SJjlp0T459+45OYL0V1FUN3pZ7pOr4TXQyjdXXjpjjOIiTc4wI4Qh2UO4lBppktH1N aMMHhGySdEiH0XBhc/UYW5qwhKi41KX37SiOAQjR05dgP4SdGkeasKL6c7E6foA00eQf tq7rvzjKeHPET9gTuII3dwTpw8Pj+5FR62OtmdOhj8TX0GInbCn2TOLFxQXYNW/6kiVS zQhw/MqN86Ssl8QYs53R4eFpBcFLC6tYWHDEftU7nDk0cJ1I6+Y8p4uI2Kt6lRb/WWmr vWN98Kq8i8bwKHFAcS59p5J30VgyN1sEYIQdbUD0Q5xE9cPBv+My0KH+xmLdK1RkIXly Iayg== MIME-Version: 1.0 X-Received: by 10.42.129.9 with SMTP id o9mr20457794ics.38.1394297735807; Sat, 08 Mar 2014 08:55:35 -0800 (PST) In-Reply-To: <1393697458.5147.YahooMailNeo@web126004.mail.ne1.yahoo.com> References: <1393697458.5147.YahooMailNeo@web126004.mail.ne1.yahoo.com> Date: Sat, 8 Mar 2014 09:55:35 -0700 Subject: Re: How to extract contents of inner text of html tag? From: Jason Friedman To: "Golam Md. Shibly" Content-Type: text/plain; charset=UTF-8 Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394297744 news.xs4all.nl 2850 [2001:888:2000:d::a6]:45658 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68045 > for line in all_kbd: > if line.string == None: I modified your code slightly: for line in all_kbd: print(line) sys.exit() if line.string == None: Running the new script yields: $ python shibly.py cp -v --remove-destination /usr/share/zoneinfo/ \ /etc/localtime Meaning that all_kbd=soup.find_all('kbd') yields only a single string, not multiple strings as I'm guessing you expected. You might also consider running your program as: python -m pdb your_program.py