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


Groups > comp.lang.python > #76401

Re: string encoding regex problem

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!diablo1.news.osn.de!news.osn.de!diablo2.news.osn.de!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'url:sourceforge': 0.03; 'encoding': 0.05; 'string': 0.09; 'mask': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:string': 0.09; 'data)': 0.16; 're.search(': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'skip:[ 50': 0.16; 'skip:r 80': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'subject:problem': 0.24; 'title,': 0.24; 'question': 0.24; 'header:X-Complaints-To:1': 0.27; 'matching': 0.30; 'code': 0.31; 'quotes': 0.31; 'yes.': 0.31; 'probably': 0.32; 'skip:t 40': 0.33; 'problem': 0.35; 'skip:u 20': 0.35; 'to:addr:python-list': 0.38; 'structure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'till': 0.61; 'sometimes.': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: string encoding regex problem
Date Sat, 16 Aug 2014 11:01:57 +0200
Organization None
References <lsm8ic$j90$1@online.de> <roy-7B58DA.20484615082014@news.panix.com> <lsmeej$49n$1@online.de>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p57bd8add.dip0.t-ipconnect.de
User-Agent KNode/4.13.2
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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>
Newsgroups comp.lang.python
Message-ID <mailman.13048.1408179734.18130.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1408179734 news.xs4all.nl 2932 [2001:888:2000:d::a6]:46644
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:76401

Show key headers only | View raw


Philipp Kraus wrote:

> The code works till last week correctly, I don't change the pattern. 

Websites' contents and structure change sometimes.

> My question is, can it be a problem with string encoding? 

Your regex is all-ascii. So an encoding problem is very unlikely.

> found = re.search( "<a 
> href=\"/projects/boost/files/latest/download\?source=files\" 
> title=\"/boost/(.*)",
> data)

> Did I mask the question mark and quotes
> correctly?

Yes.

A quick check...

>>> data = urllib.urlopen("http://sourceforge.net/projects/boost/files/boost/").read()
>>> re.compile("/projects/boost/files/latest/download\?source=files.*?>").findall(data)
['/projects/boost/files/latest/download?source=files" title="/boost-docs/1.56.0/boost_1_56_pdf.7z:  released on 2014-08-14 16:35:00 UTC">']

...reveals that the matching link has "/boost-docs/" in its title, so the
 site contents probably did change. 

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


Thread

string encoding regex problem Philipp Kraus <philipp.kraus@flashpixx.de> - 2014-08-16 02:27 +0200
  Re: string encoding regex problem Roy Smith <roy@panix.com> - 2014-08-15 20:48 -0400
    Re: string encoding regex problem Philipp Kraus <philipp.kraus@flashpixx.de> - 2014-08-16 04:08 +0200
      Re: string encoding regex problem Roy Smith <roy@panix.com> - 2014-08-15 22:14 -0400
      Re: string encoding regex problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-16 14:35 +1000
      Re: string encoding regex problem Peter Otten <__peter__@web.de> - 2014-08-16 11:01 +0200
        Re: string encoding regex problem Philipp Kraus <philipp.kraus@flashpixx.de> - 2014-08-23 22:46 +0200
          Re: string encoding regex problem Peter Otten <__peter__@web.de> - 2014-08-23 23:13 +0200

csiph-web