Python中文
首页
教程
问答
标签
搜索
登录
注册
正则表达式来提取以相同u开头的页面
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我想写一个正则表达式,使我能够提取网页开始与相同的网址。你知道吗</p> <p>例如:我有以下网址</p> <pre><code> https://www.afp.com/fr/infos/334/soudan-le-president-dechu-en-prison-les-manifestants-toujours-mobilises-doc-1fp9z64 </code></pre> <p>并且只想创建以下url:</p> <pre><code>https://www.afp.com/fr/infos/334/ </code></pre> <p>这样我就可以:</p> <pre><code>https://www.afp.com/fr/infos/334/le barça-est-gagnant https://www.afp.com/fr/infos/334/mort au Zimbabwe https://www.afp.com/fr/infos/334/le président français </code></pre> <p>所以我试过了</p> <pre><code>https://www.afp.com/fr/infos/334/* https://www.afp.com/fr/infos/334/[^abc]* </code></pre> <p>它不工作,我必须把正则表达式在一个软件做爬行,该软件是用python编写的</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>你应该像这样使用<a href="https://docs.python.org/3/library/stdtypes.html#str.startswith" rel="nofollow noreferrer">^{<cd1>}</a></p> <pre><code>if url.startswith('https://www.afp.com/fr/infos/334/'): # do stuff with url </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
VirtualEnvRapper错误:路径python2(来自python=python2)不存在
4 回答
virtualenvs上的pyinstaller,没有名为导入错误的模块
1 回答
virtualenvs是否可以退回到用户包而不是系统包?
2 回答
virtualenvwrapper CentOS7
5 回答
virtualenvwrapper IOError:[Errno 13]权限被拒绝
6 回答
virtualenvwrapper mkproject和shell在windows中的启动问题?
2 回答
virtualenvwrapper mkvirtualenv不工作但没有错误
2 回答
Virtualenvwrapper python bash
3 回答
virtualenvwrapper:“workon”何时更改到项目目录?
8 回答
virtualenvwrapper:mkvirtualenv可以工作,但是rmvirtualenv返回bash:没有这样的文件或目录
6 回答
virtualenvwrapper:virtualenv信息存储在哪里?
6 回答
virtualenvwrapper:命令“python设置.pyegg_info“失败,错误代码为1
1 回答
virtualenvwrapper:如何将mkvirtualenv的默认Python版本/路径更改为ins
8 回答
Virtualenvwrapper:模块“pkg_resources”没有属性“iter_entry_points”
4 回答
Virtualenvwrapper:没有名为virtualenvwrapp的模块
10 回答
Virtualenvwrapper.bash_profi的正确设置
3 回答
Virtualenvwrapper.hook:权限被拒绝
9 回答
virtualenvwrapper.sh:fork:资源暂时不可用Python/Djang
9 回答
Virtualenvwrapper.shlssitepackages命令不工作
7 回答
Virtualenvwrapper.sh函数在bash sh中不可用
10 回答