Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76401
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: string encoding regex problem |
| Date | 2014-08-16 11:01 +0200 |
| Organization | None |
| References | <lsm8ic$j90$1@online.de> <roy-7B58DA.20484615082014@news.panix.com> <lsmeej$49n$1@online.de> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13048.1408179734.18130.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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