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: 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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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( " 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.