Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99510

Re: Screen scraper to get all 'a title' elements

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Screen scraper to get all 'a title' elements
Date Thu, 26 Nov 2015 10:54:04 +1100
Lines 36
Message-ID <mailman.105.1448495654.20593.python-list@python.org> (permalink)
References <23ed6f4b-0ef2-4c9e-ade6-e597e7e03ca2@googlegroups.com> <mailman.96.1448484959.20593.python-list@python.org> <n35ckk$9q0$1@dont-email.me> <c1e43997-0da3-4b93-b9af-98a2568eff9d@googlegroups.com> <mailman.103.1448492791.20593.python-list@python.org> <n35h0v$stn$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de hJ3TRLZnwaLoCaJ1ge+i9wyF+0EbzKJ6/bFane/I0ZKg==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'broken': 0.03; 'received:209.85.223': 0.03; 'expressions': 0.07; "subject:' ": 0.07; 'cc:addr:python-list': 0.09; 'compact': 0.09; 'parsed': 0.09; ':-)': 0.12; 'thu,': 0.15; 'describing': 0.16; 'expressions,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'side.': 0.16; 'soup': 0.16; 'uses,': 0.16; 'wrote:': 0.16; 'language': 0.19; '>>>': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'parse': 0.22; 'parsing': 0.22; 'sorry,': 0.22; 'suppose': 0.22; 'trying': 0.22; 'am,': 0.23; 'seems': 0.23; 'header:In-Reply-To:1': 0.24; 'chris': 0.26; 'message-id:@mail.gmail.com': 0.27; 'regular': 0.29; 'doing?': 0.29; 'that.': 0.30; 'code': 0.30; 'mention': 0.30; 'programmers': 0.30; 'subject:all': 0.32; 'html,': 0.33; 'list': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'text': 0.35; 'nov': 0.35; 'but': 0.36; 'too': 0.36; 'there': 0.36; 'tool': 0.36; 'received:209.85': 0.36; "wasn't": 0.36; 'subject:: ': 0.37; 'being': 0.37; 'received:209': 0.38; 'stuff': 0.38; 'wrong': 0.38; 'end': 0.39; 'why': 0.39; 'does': 0.39; 'easily': 0.39; 'where': 0.40; 'some': 0.40; 'side': 0.62; 'more': 0.63; 'places': 0.64; 'beautiful': 0.66; "they're": 0.66; '26,': 0.72; 'subject:get': 0.81; 'chrisa': 0.84; 'dark': 0.84; 'ready-made': 0.84; 'wanted,': 0.84; 'to:none': 0.91; 'innocent': 0.91; 'good,': 0.93; 'reliable,': 0.93
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:cc :content-type; bh=o7jbetgspFSaiP1VvebhLNgLO+R3DGDkzb8a6r7/pmA=; b=brMKCd5LDFfUZHh+Gr+SvI7mGiKt43EgnqnPukKXHdKHWLPu52bShusvtbI7ueU3YB 7qrAmMKZxGBLmTR0Q2PbHIX1RvEWCtKZ+MNMQ/oyUoZ/+8c5kyGAw/ZMkAH5hGeQXZuh CegBHZbJoDLnUExH0d7/oDhd/593MSJnOenfmToju/U5lwNgBkXqh84ZlwWKukWMNviQ ZMnBgzIPCq29LN2Px9zhp01qh5uuzfXfHObP7kxROMSHbnM8RDniA3Wujq9kVSSmT6nF duJhYotUahh/2r2uUISG9sADVrHSNuNLCwoMksVo2G4SXf8MGDCV8iSn4b2HOuxOi82Q Ee8Q==
X-Received by 10.107.16.84 with SMTP id y81mr35389077ioi.19.1448495644785; Wed, 25 Nov 2015 15:54:04 -0800 (PST)
In-Reply-To <n35h0v$stn$1@dont-email.me>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:99510

Show key headers only | View raw


On Thu, Nov 26, 2015 at 10:44 AM, Grobu <snailcoder@retrosite.invalid> wrote:
> On 26/11/15 00:06, Chris Angelico wrote:
>>
>> On Thu, Nov 26, 2015 at 9:48 AM, ryguy7272 <ryanshuell@gmail.com> wrote:
>>>
>>> Thanks!!  Is that regex?  Can you explain exactly what it is doing?
>>> Also, it seems to pick up a lot more than just the list I wanted, but
>>> that's ok, I can see why it does that.
>>>
>>> Can you just please explain what it's doing???
>>
>>
>> It's a trap!
>>
>> Don't use a regex to parse HTML, unless you're deliberately trying to
>> entice young and innocent programmers to the dark side.
>>
>> ChrisA
>>
>
> Sorry, I wasn't aware of regex being on the dark side :-)
> Now that you mention it, I suppose that their being complex and
> error-inducing could lead to broken code all too easily when there is a
> reliable, ready-made solution like BeautifulSoup.

Regular expressions have their uses, but parsing HTML is not one of
them. The most important use of a regex is letting an end user control
the search pattern; it's a compact language for describing a variety
of text search concepts. For hard-coded regular expressions, there are
some places where they're very good, and a lot of places where they're
the wrong tool for the job. And one of those wrong-tool-for-job places
is parsing stuff that fundamentally cannot be parsed with regexes,
such as HTML. You _need_ a proper parser, which is what Beautiful Soup
is for.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Screen scraper to get all 'a title' elements ryguy7272 <ryanshuell@gmail.com> - 2015-11-25 12:42 -0800
  Re: Screen scraper to get all 'a title' elements MRAB <python@mrabarnett.plus.com> - 2015-11-25 20:55 +0000
    Re: Screen scraper to get all 'a title' elements Grobu <snailcoder@retrosite.invalid> - 2015-11-25 23:30 +0100
      Re: Screen scraper to get all 'a title' elements ryguy7272 <ryanshuell@gmail.com> - 2015-11-25 14:48 -0800
        Re: Screen scraper to get all 'a title' elements Chris Angelico <rosuav@gmail.com> - 2015-11-26 10:06 +1100
          Re: Screen scraper to get all 'a title' elements Grobu <snailcoder@retrosite.invalid> - 2015-11-26 00:44 +0100
            Re: Screen scraper to get all 'a title' elements Marko Rauhamaa <marko@pacujo.net> - 2015-11-26 01:53 +0200
              Re: Screen scraper to get all 'a title' elements Chris Angelico <rosuav@gmail.com> - 2015-11-26 10:59 +1100
            Re: Screen scraper to get all 'a title' elements Chris Angelico <rosuav@gmail.com> - 2015-11-26 10:54 +1100
            Re: Screen scraper to get all 'a title' elements Grobu <snailcoder@retrosite.invalid> - 2015-11-26 02:05 +0100
        Re: Screen scraper to get all 'a title' elements Grobu <snailcoder@retrosite.invalid> - 2015-11-26 00:33 +0100
          Re: Screen scraper to get all 'a title' elements ryguy7272 <ryanshuell@gmail.com> - 2015-11-25 15:37 -0800
            Re: Screen scraper to get all 'a title' elements Chris Angelico <rosuav@gmail.com> - 2015-11-26 10:42 +1100
  Re: Screen scraper to get all 'a title' elements ryguy7272 <ryanshuell@gmail.com> - 2015-11-25 14:04 -0800
    Re: Screen scraper to get all 'a title' elements Chris Angelico <rosuav@gmail.com> - 2015-11-26 09:10 +1100
  Re: Screen scraper to get all 'a title' elements TP <wingusr@gmail.com> - 2015-11-25 17:15 -0800
  Re: Screen scraper to get all 'a title' elements Denis McMahon <denismfmcmahon@gmail.com> - 2015-11-26 14:49 +0000

csiph-web